NULL fields after executing LENGTH(email_address)












0















I got a problem, i wanted to obtain the maximum length of a field because i wanted to know if there was fields that exceeded the size established for that field, for example : varchar2(20)



I am using oracle 11g, take a look at this:



https://i.stack.imgur.com/4DdWM.jpg



So, i did this query:



    SELECT
hp.party_name
, hca.account_number
, hca.cust_account_id
-- , hcsu.LOCATION customer_site_name
, hcas.cust_acct_site_id
, hcp.phone_number
, hcp.email_address
, hl.address1
, hl.address2
, hl.address3
, hl.address4
, hl.city
, hl.province
, hl.postal_code
, hcas.status
, DECODE( hcas.attribute5, 'PUP', 'Y', 'N' )
, hca.status
FROM apps.hz_cust_accounts hca
INNER JOIN apps.hz_cust_acct_sites_all hcas ON hca.cust_account_id = hcas.cust_account_id
INNER JOIN apps.hz_party_sites hps ON hcas.party_site_id = hps.party_site_id
INNER JOIN apps.hz_locations hl ON hps.location_id = hl.location_id
INNER JOIN apps.hz_parties hp ON hps.party_id = hp.party_id
LEFT JOIN (
SELECT
owner_table_id
, max(case when contact_point_type = 'PHONE' then phone_number end) phone_number
, max(case when contact_point_type = 'EMAIL' then email_address end) email_address
FROM hz_contact_points
WHERE status = 'A'
AND primary_flag = 'Y'
AND owner_table_name = 'HZ_PARTY_SITES'
AND contact_point_type IN ('EMAIL','PHONE')
AND length (phone_number) > 40
GROUP BY
owner_table_id
) hcp ON hcas.party_site_id = hcp.owner_table_id
WHERE hcas.status = 'A'
AND hps.status = 'A'
AND hca.status = 'A'
AND hca.account_number = ''
;


I put this condition "AND length (phone_number) > 40" but it is not working because it shows null fields, why?



Take a look at this:
IMAGE



Also, is this condition okay?



hcp ON hcas.party_site_id = hcp.owner_table_id 


Can you please help me with this?



PS: i am using SQL DEVELOPER and oracle database 11g










share|improve this question

























  • Please don't post (links to) images of table structures, code or query results, use text.

    – sticky bit
    Jan 2 at 1:05


















0















I got a problem, i wanted to obtain the maximum length of a field because i wanted to know if there was fields that exceeded the size established for that field, for example : varchar2(20)



I am using oracle 11g, take a look at this:



https://i.stack.imgur.com/4DdWM.jpg



So, i did this query:



    SELECT
hp.party_name
, hca.account_number
, hca.cust_account_id
-- , hcsu.LOCATION customer_site_name
, hcas.cust_acct_site_id
, hcp.phone_number
, hcp.email_address
, hl.address1
, hl.address2
, hl.address3
, hl.address4
, hl.city
, hl.province
, hl.postal_code
, hcas.status
, DECODE( hcas.attribute5, 'PUP', 'Y', 'N' )
, hca.status
FROM apps.hz_cust_accounts hca
INNER JOIN apps.hz_cust_acct_sites_all hcas ON hca.cust_account_id = hcas.cust_account_id
INNER JOIN apps.hz_party_sites hps ON hcas.party_site_id = hps.party_site_id
INNER JOIN apps.hz_locations hl ON hps.location_id = hl.location_id
INNER JOIN apps.hz_parties hp ON hps.party_id = hp.party_id
LEFT JOIN (
SELECT
owner_table_id
, max(case when contact_point_type = 'PHONE' then phone_number end) phone_number
, max(case when contact_point_type = 'EMAIL' then email_address end) email_address
FROM hz_contact_points
WHERE status = 'A'
AND primary_flag = 'Y'
AND owner_table_name = 'HZ_PARTY_SITES'
AND contact_point_type IN ('EMAIL','PHONE')
AND length (phone_number) > 40
GROUP BY
owner_table_id
) hcp ON hcas.party_site_id = hcp.owner_table_id
WHERE hcas.status = 'A'
AND hps.status = 'A'
AND hca.status = 'A'
AND hca.account_number = ''
;


I put this condition "AND length (phone_number) > 40" but it is not working because it shows null fields, why?



Take a look at this:
IMAGE



Also, is this condition okay?



hcp ON hcas.party_site_id = hcp.owner_table_id 


Can you please help me with this?



PS: i am using SQL DEVELOPER and oracle database 11g










share|improve this question

























  • Please don't post (links to) images of table structures, code or query results, use text.

    – sticky bit
    Jan 2 at 1:05
















0












0








0








I got a problem, i wanted to obtain the maximum length of a field because i wanted to know if there was fields that exceeded the size established for that field, for example : varchar2(20)



I am using oracle 11g, take a look at this:



https://i.stack.imgur.com/4DdWM.jpg



So, i did this query:



    SELECT
hp.party_name
, hca.account_number
, hca.cust_account_id
-- , hcsu.LOCATION customer_site_name
, hcas.cust_acct_site_id
, hcp.phone_number
, hcp.email_address
, hl.address1
, hl.address2
, hl.address3
, hl.address4
, hl.city
, hl.province
, hl.postal_code
, hcas.status
, DECODE( hcas.attribute5, 'PUP', 'Y', 'N' )
, hca.status
FROM apps.hz_cust_accounts hca
INNER JOIN apps.hz_cust_acct_sites_all hcas ON hca.cust_account_id = hcas.cust_account_id
INNER JOIN apps.hz_party_sites hps ON hcas.party_site_id = hps.party_site_id
INNER JOIN apps.hz_locations hl ON hps.location_id = hl.location_id
INNER JOIN apps.hz_parties hp ON hps.party_id = hp.party_id
LEFT JOIN (
SELECT
owner_table_id
, max(case when contact_point_type = 'PHONE' then phone_number end) phone_number
, max(case when contact_point_type = 'EMAIL' then email_address end) email_address
FROM hz_contact_points
WHERE status = 'A'
AND primary_flag = 'Y'
AND owner_table_name = 'HZ_PARTY_SITES'
AND contact_point_type IN ('EMAIL','PHONE')
AND length (phone_number) > 40
GROUP BY
owner_table_id
) hcp ON hcas.party_site_id = hcp.owner_table_id
WHERE hcas.status = 'A'
AND hps.status = 'A'
AND hca.status = 'A'
AND hca.account_number = ''
;


I put this condition "AND length (phone_number) > 40" but it is not working because it shows null fields, why?



Take a look at this:
IMAGE



Also, is this condition okay?



hcp ON hcas.party_site_id = hcp.owner_table_id 


Can you please help me with this?



PS: i am using SQL DEVELOPER and oracle database 11g










share|improve this question
















I got a problem, i wanted to obtain the maximum length of a field because i wanted to know if there was fields that exceeded the size established for that field, for example : varchar2(20)



I am using oracle 11g, take a look at this:



https://i.stack.imgur.com/4DdWM.jpg



So, i did this query:



    SELECT
hp.party_name
, hca.account_number
, hca.cust_account_id
-- , hcsu.LOCATION customer_site_name
, hcas.cust_acct_site_id
, hcp.phone_number
, hcp.email_address
, hl.address1
, hl.address2
, hl.address3
, hl.address4
, hl.city
, hl.province
, hl.postal_code
, hcas.status
, DECODE( hcas.attribute5, 'PUP', 'Y', 'N' )
, hca.status
FROM apps.hz_cust_accounts hca
INNER JOIN apps.hz_cust_acct_sites_all hcas ON hca.cust_account_id = hcas.cust_account_id
INNER JOIN apps.hz_party_sites hps ON hcas.party_site_id = hps.party_site_id
INNER JOIN apps.hz_locations hl ON hps.location_id = hl.location_id
INNER JOIN apps.hz_parties hp ON hps.party_id = hp.party_id
LEFT JOIN (
SELECT
owner_table_id
, max(case when contact_point_type = 'PHONE' then phone_number end) phone_number
, max(case when contact_point_type = 'EMAIL' then email_address end) email_address
FROM hz_contact_points
WHERE status = 'A'
AND primary_flag = 'Y'
AND owner_table_name = 'HZ_PARTY_SITES'
AND contact_point_type IN ('EMAIL','PHONE')
AND length (phone_number) > 40
GROUP BY
owner_table_id
) hcp ON hcas.party_site_id = hcp.owner_table_id
WHERE hcas.status = 'A'
AND hps.status = 'A'
AND hca.status = 'A'
AND hca.account_number = ''
;


I put this condition "AND length (phone_number) > 40" but it is not working because it shows null fields, why?



Take a look at this:
IMAGE



Also, is this condition okay?



hcp ON hcas.party_site_id = hcp.owner_table_id 


Can you please help me with this?



PS: i am using SQL DEVELOPER and oracle database 11g







sql oracle11g






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 2 at 1:01







programming_amazing

















asked Jan 2 at 0:52









programming_amazingprogramming_amazing

315




315













  • Please don't post (links to) images of table structures, code or query results, use text.

    – sticky bit
    Jan 2 at 1:05





















  • Please don't post (links to) images of table structures, code or query results, use text.

    – sticky bit
    Jan 2 at 1:05



















Please don't post (links to) images of table structures, code or query results, use text.

– sticky bit
Jan 2 at 1:05







Please don't post (links to) images of table structures, code or query results, use text.

– sticky bit
Jan 2 at 1:05














2 Answers
2






active

oldest

votes


















0














The way you modified the query doesn’t look good. You added a WHERE clause to a subquery taht is used to recover the user email and phone number from table hz_contact_point. Now it looks like the subquery does not return anything, and related’fields are NULL in the results (if you were using INNER JOIN instead of LEFT JOIN, you would have no results at all),



If you just need to control or format your output, don’t modify the subquery : it might break the logic. Use the main query. For example, the below sample replaces the phone number with NULL if it has more than 40 chars.



SELECT
hp.party_name
, hca.account_number
...
, CASE WHEN LENGTH(hcp.phone_number) > 40 THEN NULL ELSE hcp.phone_number END
, hcp.email_address
...





share|improve this answer
























  • Thank you for replying! Dude, i got this error when i tried to filfer the table in order to find all the information related to an account_number (in SQL DEVELOPER) imgur.com/a/ddgz2DA WHY?

    – programming_amazing
    Jan 2 at 1:27











  • How can i fix it?

    – programming_amazing
    Jan 2 at 1:28



















0














You left join that subquery aliased hcp, so if there are no matching rows from hcp for some rows of the other tables inner joined before, the values from hcp are NULL for these rows.



But if phone_number is declared as varchar2(40) you won't find any phone numbers with length(phone_number) > 40. They would have been rejected if some one tried to insert them.






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54000129%2fnull-fields-after-executing-lengthemail-address%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    The way you modified the query doesn’t look good. You added a WHERE clause to a subquery taht is used to recover the user email and phone number from table hz_contact_point. Now it looks like the subquery does not return anything, and related’fields are NULL in the results (if you were using INNER JOIN instead of LEFT JOIN, you would have no results at all),



    If you just need to control or format your output, don’t modify the subquery : it might break the logic. Use the main query. For example, the below sample replaces the phone number with NULL if it has more than 40 chars.



    SELECT
    hp.party_name
    , hca.account_number
    ...
    , CASE WHEN LENGTH(hcp.phone_number) > 40 THEN NULL ELSE hcp.phone_number END
    , hcp.email_address
    ...





    share|improve this answer
























    • Thank you for replying! Dude, i got this error when i tried to filfer the table in order to find all the information related to an account_number (in SQL DEVELOPER) imgur.com/a/ddgz2DA WHY?

      – programming_amazing
      Jan 2 at 1:27











    • How can i fix it?

      – programming_amazing
      Jan 2 at 1:28
















    0














    The way you modified the query doesn’t look good. You added a WHERE clause to a subquery taht is used to recover the user email and phone number from table hz_contact_point. Now it looks like the subquery does not return anything, and related’fields are NULL in the results (if you were using INNER JOIN instead of LEFT JOIN, you would have no results at all),



    If you just need to control or format your output, don’t modify the subquery : it might break the logic. Use the main query. For example, the below sample replaces the phone number with NULL if it has more than 40 chars.



    SELECT
    hp.party_name
    , hca.account_number
    ...
    , CASE WHEN LENGTH(hcp.phone_number) > 40 THEN NULL ELSE hcp.phone_number END
    , hcp.email_address
    ...





    share|improve this answer
























    • Thank you for replying! Dude, i got this error when i tried to filfer the table in order to find all the information related to an account_number (in SQL DEVELOPER) imgur.com/a/ddgz2DA WHY?

      – programming_amazing
      Jan 2 at 1:27











    • How can i fix it?

      – programming_amazing
      Jan 2 at 1:28














    0












    0








    0







    The way you modified the query doesn’t look good. You added a WHERE clause to a subquery taht is used to recover the user email and phone number from table hz_contact_point. Now it looks like the subquery does not return anything, and related’fields are NULL in the results (if you were using INNER JOIN instead of LEFT JOIN, you would have no results at all),



    If you just need to control or format your output, don’t modify the subquery : it might break the logic. Use the main query. For example, the below sample replaces the phone number with NULL if it has more than 40 chars.



    SELECT
    hp.party_name
    , hca.account_number
    ...
    , CASE WHEN LENGTH(hcp.phone_number) > 40 THEN NULL ELSE hcp.phone_number END
    , hcp.email_address
    ...





    share|improve this answer













    The way you modified the query doesn’t look good. You added a WHERE clause to a subquery taht is used to recover the user email and phone number from table hz_contact_point. Now it looks like the subquery does not return anything, and related’fields are NULL in the results (if you were using INNER JOIN instead of LEFT JOIN, you would have no results at all),



    If you just need to control or format your output, don’t modify the subquery : it might break the logic. Use the main query. For example, the below sample replaces the phone number with NULL if it has more than 40 chars.



    SELECT
    hp.party_name
    , hca.account_number
    ...
    , CASE WHEN LENGTH(hcp.phone_number) > 40 THEN NULL ELSE hcp.phone_number END
    , hcp.email_address
    ...






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Jan 2 at 1:13









    GMBGMB

    15.9k3824




    15.9k3824













    • Thank you for replying! Dude, i got this error when i tried to filfer the table in order to find all the information related to an account_number (in SQL DEVELOPER) imgur.com/a/ddgz2DA WHY?

      – programming_amazing
      Jan 2 at 1:27











    • How can i fix it?

      – programming_amazing
      Jan 2 at 1:28



















    • Thank you for replying! Dude, i got this error when i tried to filfer the table in order to find all the information related to an account_number (in SQL DEVELOPER) imgur.com/a/ddgz2DA WHY?

      – programming_amazing
      Jan 2 at 1:27











    • How can i fix it?

      – programming_amazing
      Jan 2 at 1:28

















    Thank you for replying! Dude, i got this error when i tried to filfer the table in order to find all the information related to an account_number (in SQL DEVELOPER) imgur.com/a/ddgz2DA WHY?

    – programming_amazing
    Jan 2 at 1:27





    Thank you for replying! Dude, i got this error when i tried to filfer the table in order to find all the information related to an account_number (in SQL DEVELOPER) imgur.com/a/ddgz2DA WHY?

    – programming_amazing
    Jan 2 at 1:27













    How can i fix it?

    – programming_amazing
    Jan 2 at 1:28





    How can i fix it?

    – programming_amazing
    Jan 2 at 1:28













    0














    You left join that subquery aliased hcp, so if there are no matching rows from hcp for some rows of the other tables inner joined before, the values from hcp are NULL for these rows.



    But if phone_number is declared as varchar2(40) you won't find any phone numbers with length(phone_number) > 40. They would have been rejected if some one tried to insert them.






    share|improve this answer




























      0














      You left join that subquery aliased hcp, so if there are no matching rows from hcp for some rows of the other tables inner joined before, the values from hcp are NULL for these rows.



      But if phone_number is declared as varchar2(40) you won't find any phone numbers with length(phone_number) > 40. They would have been rejected if some one tried to insert them.






      share|improve this answer


























        0












        0








        0







        You left join that subquery aliased hcp, so if there are no matching rows from hcp for some rows of the other tables inner joined before, the values from hcp are NULL for these rows.



        But if phone_number is declared as varchar2(40) you won't find any phone numbers with length(phone_number) > 40. They would have been rejected if some one tried to insert them.






        share|improve this answer













        You left join that subquery aliased hcp, so if there are no matching rows from hcp for some rows of the other tables inner joined before, the values from hcp are NULL for these rows.



        But if phone_number is declared as varchar2(40) you won't find any phone numbers with length(phone_number) > 40. They would have been rejected if some one tried to insert them.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 2 at 1:04









        sticky bitsticky bit

        15.1k101632




        15.1k101632






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54000129%2fnull-fields-after-executing-lengthemail-address%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Monofisismo

            Angular Downloading a file using contenturl with Basic Authentication

            Olmecas