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!

Using a bulk collect with an execute immediate

571956Jan 9 2009 — edited Jan 9 2009
I am trying to do a BULK COLLECT in an EXECUTE IMMEDIATE because I need to populate my Associative Array dynamically given the schema that is passed into my procedure. Below is my code:

EXECUTE IMMEDIATE
'SELECT *
FROM test.loading_dock_external lde
INNER JOIN '||v_project||'.calling_pool cp ON lde.id = cp.id_number
AND cp.status NOT IN (''X'',''D'')
WHERE project_id = '''||v_project||''' '
BULK COLLECT INTO refresh_data ;

1.) test.loading_dock_external is an external table
2.) refresh_data is my associative array, here is the code for creating the array type and the refresh_data declaration:

TYPE refresh_file_t IS TABLE OF test.loading_dock%ROWTYPE ;
refresh_data refresh_file_t ;

Here is the error I get when I run my package:
ORA-00932: inconsistent datatypes: expected - got -
ORA-06512: at "RCDTPUMP.NOVUS", line 147
ORA-06512: at "RCDTPUMP.NOVUS_LOAD", line 1120
ORA-06512: at line 1
00932. 00000 - "inconsistent datatypes: expected %s got %s"
*Cause:
*Action:

I was doing this in straight SQL and it worked fine, but I am trying to make my PL/SQL package more efficient so I am wanting to add in my INNER JOIN, but to do that I need to be able to dynamically set the schema on the CALLING_POOL table.

Any help or tips would be great appreciated!
ivalum21
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 6 2009
Added on Jan 9 2009
3 comments
3,464 views