Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

UNION ALL in BULK COLLECT

RNMar 1 2012 — edited Mar 19 2012
My code is like this:
SELECT COL_NAME, COUNT BULK COLLECT INTO v_collections FROM
(
SELECT 'PROD_NAME' COL_NAME, COUNT(*) COUNT FROM TEST_TABLE
WHERE LENGTH(PROD_NAME)>50  
UNION ALL
SELECT 'PROD_DESC' COL_NAME, COUNT(*) COUNT FROM TEST_TABLE
WHERE PROD_DESC IS NULL
.
.
.
..10 MORE UNION ALL
);
{code}

--does it lead to one context switch or multiple one for each select in the union all
--I do want to capture # of errors for each column 
--although the code runs very fast, still I am worried that it may not be a good coding practice.
--is there any better way to do this?
--TEST_TABLE has 1 million records

Thanks,
RN                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
This post has been answered by unknown-7404 on Mar 1 2012
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 16 2012
Added on Mar 1 2012
8 comments
3,352 views