?
Solved

bulk collect in dynamic sql

Posted on 2014-10-24
3
Medium Priority
?
282 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 1500 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to take different types of Oracle backups using RMAN.
Suggested Courses

752 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