And util.array is type array is table of varchar2(4000) index by binary_integer;
The pl/sql with the "execute immediate" statement doesn't compile - and I understand why - but the question is can anyone tell me how (if) this can be done? It does need to be dynamic.....
-- jeremy
Oracle 9iR2 Solaris 8 Oracle HTTP Server and mod_plsql
"Jeremy" <jeremy0505@gmail.com> a йcrit dans le message de news: MPG.1eb7036f3bac3c2e98a191@news.individual.net... | | Want to call target procedure using dynamic SQL. | | Target procedure is defined thus: | | create or replace package vr is | procedure form_1 | (p_id in number default null, | p_name in util.array default util.empty_array, | p_value in util.array default util.empty_array); | | Now I want to call this using dynamic sql e.g. | | execute immediate | 'begin vr.procname(p_id=>1,p_name=>'||l_name||'); end;'; | | where l_name is defined as | | l_name util.array; | | And util.array is | type array is table of varchar2(4000) index by binary_integer; | | The pl/sql with the "execute immediate" statement doesn't compile - and | I understand why - but the question is can anyone tell me how (if) this | can be done? It does need to be dynamic..... | | | -- | jeremy | | Oracle 9iR2 | Solaris 8 | Oracle HTTP Server and mod_plsql
|> | The pl/sql with the "execute immediate" statement doesn't compile - and> | I understand why - but the question is can anyone tell me how (if) this> | can be done? It does need to be dynamic.....> |>
Why not just:>
vr.procname(p_id=>1,p_name=>l_name);
Becase we don't know the name of "vr.procname" - as I said, it needs to be a dynamic SQL call (or another method where the actual proc name isn't known until runtime - but that *is* dynamic SQL) --
"Jeremy" <jeremy0505@gmail.com> a йcrit dans le message de news: MPG.1eb7078838ec738498a192@news.individual.net... In article <444cf591$0$27282$626a54ce@news.free.fr>, says...>
"Jeremy" <jeremy0505@gmail.com> a йcrit dans le message de news: MPG.1eb7036f3bac3c2e98a191@news.individual.net...> |
|> | The pl/sql with the "execute immediate" statement doesn't compile - and> | I understand why - but the question is can anyone tell me how (if) this> | can be done? It does need to be dynamic.....> |>
Why not just:>
vr.procname(p_id=>1,p_name=>l_name);
Becase we don't know the name of "vr.procname" - as I said, it needs to be a dynamic SQL call (or another method where the actual proc name isn't known until runtime - but that *is* dynamic SQL) --
jeremy
So now we know you really need dynamic SQL, what does mean "The pl/sql with the "execute immediate" statement doesn't compile"? I never saw Oracle displaying such an error message.
In article <444cf970$0$27281$626a54ce@news.free.fr>, says...
So now we know you really need dynamic SQL, what does mean> "The pl/sql with the "execute immediate" statement doesn't compile"?> I never saw Oracle displaying such an error message.
OK you caught me - I didn't expect the pl/sql to compile as the execute immediate statement requires a strcing defining the SQL statement to be run and I was trying to effectively concatenate an array with a string which was never going to work.
833/2 PL/SQL: Statement ignored
834/4 PLS-00306: wrong number or types of arguments in call to '||'
l_name should be defined as a string, shouldn't it? your l_name is a collection, right? so you try to concatenate a string with a collection ... seems strange!
In article <1145896879.150069.234400@e56g2000cwe.googlegroups.com>, steph says...> l_name should be defined as a string, shouldn't it? your l_name is a> collection, right? so you try to concatenate a string with a collection> ... seems strange!>
Which was exactly my point. I want to pass the collection as a parameter to a procedure whose name we do not know until run-time - and I want to know if this is possible.
And util.array is > type array is table of varchar2(4000) index by binary_integer;>
The pl/sql with the "execute immediate" statement doesn't compile - and > I understand why - but the question is can anyone tell me how (if) this > can be done? It does need to be dynamic.....>
Something along the line of: declare g_proc varchar2(40) := 'vr.procname'; g_name varchar2(40) := 'l_name'; begin execute immediate ( ':l_procname(p_id=>1,p_name=>:l_name' ) using g_proc, g_name; end;
as far as i know you can't pass collections as parameter of execute immediate. maybe you can change your procedure(s) in a way that it don't needs the parameter - with a package that handles these collections and your procedure(s) accessing this package (or being part of this package).
In article <e2j44j$u4h$1@news5.zwoll1.ov.home.nl>, Frank van Bortel says...
Something along the line of:> declare> g_proc varchar2(40) := 'vr.procname';> g_name varchar2(40) := 'l_name';> begin> execute immediate (> ':l_procname(p_id=>1,p_name=>:l_name'> )> using g_proc, g_name;> end;>
?>
Not sure exactly waht you're getting at here Frank - doesn't that just literally pass the string value 'l_name' into the p_name param of vr.procname?
I need to find a way to pass an array param to a stored procedure using some form of dynamic SQL. Perhaps it is not possible with "execute immediate" - perhaps only with DBMS_SQL?
Connor McDonald 26 April 2006 17:38:19 [ permanent link ]
Jeremy wrote:>
Want to call target procedure using dynamic SQL.>
Target procedure is defined thus:>
create or replace package vr is> procedure form_1> (p_id in number default null,> p_name in util.array default util.empty_array,> p_value in util.array default util.empty_array);>
And util.array is> type array is table of varchar2(4000) index by binary_integer;>
The pl/sql with the "execute immediate" statement doesn't compile - and> I understand why - but the question is can anyone tell me how (if) this> can be done? It does need to be dynamic.....>
--> jeremy>
Oracle 9iR2> Solaris 8> Oracle HTTP Server and mod_plsql
execute immediate 'begin vr.procname(p_id=>1,p_name=>:b1); end;' using l_name;
hth Connor -- Connor McDonald Co-author: "Mastering Oracle PL/SQL - Practical Solutions" Co-author: "Oracle Insight - Tales of the OakTable"
In article <1145949635.345961.308770@u72g2000cwu.googlegroups.com>, steph says...> as far as i know you can't pass collections as parameter of execute> immediate. maybe you can change your procedure(s) in a way that it> don't needs the parameter - with a package that handles these> collections and your procedure(s) accessing this package (or being part> of this package).>
stephan>
I don't see how it can be done - trying to compile proc where it refers to an array variable in the using clause results in an oracle error ora- 00457 - expressions have to be of SQL types.
create pacakge AAA is l_name util.array; procedure set_collection(p_name in util.array default util.empty_array); procedure form_1(); -- this is using l_name procedure form_2(); -- this is also using l_name end AAA; /
then you can call your procedures dynamically - you only need to set l_name beforehand. but of course i don't now if this is applicable in your situation ...
"Jeremy" <jeremy0505@gmail.com> wrote in message news:MPG.1eb988b5dc6e5f9898a196@news.individual.net... : In article <1145949635.345961.308770@u72g2000cwu.googlegroups.com>, : steph says... : > as far as i know you can't pass collections as parameter of execute : > immediate. maybe you can change your procedure(s) in a way that it : > don't needs the parameter - with a package that handles these : > collections and your procedure(s) accessing this package (or being part : > of this package). : > : > stephan : > : > : : I don't see how it can be done - trying to compile proc where it refers : to an array variable in the using clause results in an oracle error ora- : 00457 - expressions have to be of SQL types. : : I am a bit stuck at the moment.... : : : cheers : : : -- : : jeremy
a varray or nested table would qualify as a SQL type -- have you tried that?
And util.array is> > type array is table of varchar2(4000) index by binary_integer;> >
The pl/sql with the "execute immediate" statement doesn't compile - and> > I understand why - but the question is can anyone tell me how (if) this> > can be done? It does need to be dynamic.....>
execute immediate> 'begin vr.procname(p_id=>1,p_name=>:b1); end;'> using l_name;>
This is my example:
create or replace procedure p is l_namewd_util.array; begin begin execute immediate 'begin myproc(p_web_site_id=>3,p_name=>:b1); end;' using in l_name; exception when others then dbms_output.put_line(sqlerrm(sqlcode)); end; end p; /
Fails to compile with a PLS-00457: expressions have to be of SQL types
If I change the data type of l_name to say varchar2 then it compiles fine.
Is there a method ny which I might pass an array like this into a procedure executed via dynamic SQL?
In article <1146059874.455302.171200@v46g2000cwv.googlegroups.com>, steph says...> What i meant was something like:>
create pacakge AAA is> l_name util.array;> procedure set_collection(p_name in util.array default> util.empty_array);> procedure form_1(); -- this is using l_name> procedure form_2(); -- this is also using l_name> end AAA;> />
then you can call your procedures dynamically - you only need to set> l_name beforehand. but of course i don't now if this is applicable in> your situation ...>
This is probably me needing to do some more research here Steph because I don't undersatnd how we get from that to what I want... thanks for the pointers, appreciate the assistance. --
In article <itGdnQyI2so2H9LZnZ2dnUVZ_tmdnZ2d@comcast.com>, Mark C. Stock says...>
"Jeremy" <jeremy0505@gmail.com> wrote in message > news:MPG.1eb988b5dc6e5f9898a196@news.individual.net...> : In article <1145949635.345961.308770@u72g2000cwu.googlegroups.com>,> : steph says...> : > as far as i know you can't pass collections as parameter of execute> : > immediate. maybe you can change your procedure(s) in a way that it> : > don't needs the parameter - with a package that handles these> : > collections and your procedure(s) accessing this package (or being part> : > of this package).
:> : I don't see how it can be done - trying to compile proc where it refers> : to an array variable in the using clause results in an oracle error ora-> : 00457 - expressions have to be of SQL types.> :> : I am a bit stuck at the moment....> :> :> : cheers> :> :> : -- > :> : jeremy>
a varray or nested table would qualify as a SQL type -- have you tried that?>
Hi Mark,
I haven't tried that - that is creating a type in the database first, yes?
I wanted to explore all avenues which didn't require me to define a type in the database (as to be honest it is because I haven't been down that path before).
"Jeremy" <jeremy0505@gmail.com> wrote in message news:MPG.1eb99ab4ef05cb798a199@news.individual.net... : In article <itGdnQyI2so2H9LZnZ2dnUVZ_tmdnZ2d@comcast.com>, Mark C. Stock : says... ... : > : > a varray or nested table would qualify as a SQL type -- have you tried that? : > : : Hi Mark, : : I haven't tried that - that is creating a type in the database first, : yes? : : I wanted to explore all avenues which didn't require me to define a type : in the database (as to be honest it is because I haven't been down that : path before). :
it may be doable just in the package without creating a persistent type in the database ... worth a try
In article <H4-dnUcTFd29FtLZRVn-sg@comcast.com>, Mark C. Stock says...>
"Jeremy" <jeremy0505@gmail.com> wrote in message > news:MPG.1eb99ab4ef05cb798a199@news.individual.net...> : In article <itGdnQyI2so2H9LZnZ2dnUVZ_tmdnZ2d@comcast.com>, Mark C. Stock> : says...> ...> : >> : > a varray or nested table would qualify as a SQL type -- have you tried > that?> : >> :> : Hi Mark,> :> : I haven't tried that - that is creating a type in the database first,> : yes?> :> : I wanted to explore all avenues which didn't require me to define a type> : in the database (as to be honest it is because I haven't been down that> : path before).> :>
it may be doable just in the package without creating a persistent type in > the database ... worth a try>
Any examples of this (new area for me) - or keywords to search oracle doc on?
In article <MPG.1eb9a045dc7647c498a19a@news.individual.net>, Jeremy says...> In article <H4-dnUcTFd29FtLZRVn-sg@comcast.com>, Mark C. Stock says...> >
it may be doable just in the package without creating a persistent type in > > the database ... worth a try> >
Any examples of this (new area for me) - or keywords to search oracle > doc on?>
Follow-up on own post time:
This compiled OK:
create type mytype as table of varchar2(2000) /
create or replace procedure p is l_namemytype; begin begin execute immediate 'begin myproc(p_web_site_id=>3,p_name=>:b1); end;' using in l_name; exception when others then dbms_output.put_line(sqlerrm(sqlcode)); end; end p; / sho err
So changing the definition of l_name to be of type "mytype" instead of wd_util.array
Frank van Bortel 26 April 2006 21:45:32 [ permanent link ]
Jeremy wrote:> In article <e2j44j$u4h$1@news5.zwoll1.ov.home.nl>, Frank van Bortel > says...>
Something along the line of:>> declare>> g_proc varchar2(40) := 'vr.procname';>> g_name varchar2(40) := 'l_name';>> begin>> execute immediate (>> ':l_procname(p_id=>1,p_name=>:l_name'>> )>> using g_proc, g_name;>> end;>>
?>>
Not sure exactly waht you're getting at here Frank - doesn't that just > literally pass the string value 'l_name' into the p_name param of > vr.procname?>
I need to find a way to pass an array param to a stored procedure using > some form of dynamic SQL. Perhaps it is not possible with "execute > immediate" - perhaps only with DBMS_SQL?>
1) It uses bind variables. 2) it passes the value (contents) of g_name (in this example that would be "l_name" indeed). 3) Haven't tested with arrays, but here's your framework; pass the array. -- Regards, Frank van Bortel
In article <e2obhd$uqk$1@news4.zwoll1.ov.home.nl>, Frank van Bortel says...> Jeremy wrote:> > In article <e2j44j$u4h$1@news5.zwoll1.ov.home.nl>, Frank van Bortel > > says...> >
Something along the line of:> >> declare> >> g_proc varchar2(40) := 'vr.procname';> >> g_name varchar2(40) := 'l_name';> >> begin> >> execute immediate (> >> ':l_procname(p_id=>1,p_name=>:l_name'> >> )> >> using g_proc, g_name;> >> end;> >>
?> >>
Not sure exactly waht you're getting at here Frank - doesn't that just > > literally pass the string value 'l_name' into the p_name param of > > vr.procname?> >
I need to find a way to pass an array param to a stored procedure using > > some form of dynamic SQL. Perhaps it is not possible with "execute > > immediate" - perhaps only with DBMS_SQL?> >
1) It uses bind variables.> 2) it passes the value (contents) of g_name (in this example> that would be "l_name" indeed).> 3) Haven't tested with arrays, but here's your framework; pass the> array.>
Don't know if you've seen my other posts following up on this but it seems you cannot do it unless the type of the variable (l_name in this case) is a SQL type. So I created a type vc2000_array and used that definition for l_name - and got successful compile. Then I discovered my next set of issues under the thread "Passing array values into pl/sql procedure via a URL"
And util.array is> > > type array is table of varchar2(4000) index by binary_integer;> > >
The pl/sql with the "execute immediate" statement doesn't compile - and> > > I understand why - but the question is can anyone tell me how (if) this> > > can be done? It does need to be dynamic.....> >
execute immediate> > 'begin vr.procname(p_id=>1,p_name=>:b1); end;'> > using l_name;> >
This is my example:>
create or replace procedure p> is> l_name wd_util.array;> begin> begin> execute immediate> 'begin myproc(p_web_site_id=>3,p_name=>:b1); end;'> using in l_name;> exception> when others then> dbms_output.put_line(sqlerrm(sqlcode));> end;> end p;> />
Fails to compile with a> PLS-00457: expressions have to be of SQL types>
If I change the data type of l_name to say varchar2 then it compiles> fine.>
Is there a method ny which I might pass an array like this into a> procedure executed via dynamic SQL?>
-->
jeremy
Can you recast wd_util.array as a nested table type (I assume its a plsql table currently).
Cheers Connor
-- Connor McDonald Co-author: "Mastering Oracle PL/SQL - Practical Solutions" Co-author: "Oracle Insight - Tales of the OakTable"
If you would like to report an abuse of our service, such as a spam message, please . Если Вы хотите пожаловаться на содержимое этой страницы, пожалуйста .