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!

execute immediate will work in SQL Block in shell script?

871594May 10 2012 — edited May 10 2012
Hi Friends,

i am wirting script to get the account id's corresponding to CIF from oracle table and need to pass to procedure.
Here first_org and last_org are shell variables.
When i execute the below program it is throwing execute not found.

Can you please correct me where i made a mistake? and also please let me know how to display some content in below sql block ?dbms_output.put_line or print which need to use and provide me the syntax for both.


`sqlplus -s crmuser/******@dotis11<<ENDOFSQL
whenever sqlerror exit 1
declare
qstr varchar2(200);
facid varchar2(20);
Lacid varchar2(20);
begin

qstr:='select ACCOUNTID from accounts where ORGKEY=:1';
execute immediate qstr into facid using $first_org;
dbms_output.put_line(facid);
qstr:='select ACCOUNTID from accounts where ORGKEY=:1';
execute immediate qstr into Lacid using $last_org;
dbms_output.put_line(Lacid);
exec Retail_Otu_Dedup_Account(facid,Lacid)
end;
/
exit;
ENDOFSQL`

Thanks,
Venkat Vadlamudi.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 7 2012
Added on May 10 2012
5 comments
1,201 views