Solved

bulk collect in dynamic sql

Posted on 2014-10-24
3
279 Views
Last Modified: 2015-04-08
Why is the syntax for returning the column values as a collection so complicated when using dynamic sql in pl/sql?

For example why is the syntax like:

EXECUTE IMMEDIATE 'DELETE FROM bulk_collect_test RETURNING object_id INTO :1' returning bulk collect into l_tab;

And not like:

EXECUTE IMMEDIATE 'DELETE FROM bulk_collect_test RETURNING object_id BULK COLLECT INTO :1' USING l_tab(i);

Basically why do we need to use RETURNING clause twice - once returning the object_id values into :1 and once again returning bulk collect.
Also how does oracle substitute the bind variable :1 i.e. how does it correlate the variable :1 and the collection l_tab?

By learning the right syntax I can write the statement correctly but wanted to understand the reason the syntax was not made any simpler.

Thanks in advance.
0
Comment
Question by:subratoc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 40402048
First question I have is:
Why are you using 'execute immediate' with a delete statement?

My guess for the two returning clauses:  Scope.

execute immediate has its own syntax and the statement executed by it has its own syntax.

Again, this is only a guess.
0
 

Author Comment

by:subratoc
ID: 40411095
Actually I was trying to learn how to bulk collect the values of a column while deleting using dynamic sql.
I may never need to use this in real life but was just curious about the syntax.
0
 
LVL 77

Accepted Solution

by:
slightwv (䄆 Netminder) earned 500 total points
ID: 40411158
I'm not seeing the need to delete using dynamic SQL.  If you want to learn something that will likely never come up, then by all means, go ahead.

As far as the question asked:  but wanted to understand the reason the syntax was not made any simpler.

I cannot say.
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question