dbTalk Databases Forums  

Multi-statements SQL and stored_procedure calls

comp.database.oracle comp.database.oracle


Discuss Multi-statements SQL and stored_procedure calls in the comp.database.oracle forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
SerGioGio
 
Posts: n/a

Default Multi-statements SQL and stored_procedure calls - 05-08-2005 , 05:57 AM






Hello guys,

I would like my app to generate and execute cross platform (sybase and
oracle) multi-statement SQL in the form:

(situation A)
SQL += BEGIN();
SQL += SP("my_stored_proce", "arg1, arg2, arg3") + EOS();
SQL += "INSERT INTO my_table VALUES(1)" + EOS();
SQL += END();
dbExecute(SQL); // ODBC

or only:

(situation B)
SQL = SP("my_stored_proce", "arg1, arg2, arg3")
dbExecute(SQL); // ODBC

In sybase, the functions BEGIN, END, SP, and EOS are:
BEGIN() returns "BEGIN"
END() returns "END"
SP(my_sp, args) returns "EXEC " + my_sp + " " + args
EOS() returns "\n"

In oracle, I define these functions:
BEGIN() returns "BEGIN"
END() returns "END;"
EOS() returns ";\n"

But the problem is with the definition of SP
- if SP(my_sp, args) returns "EXEC " + my_sp + " (" + args + ")"
then (situation B) works but (situation A) fails because apparently you
cannot have EXEC inside a begin...end block
- if SP(my_sp, args) returns my_sp + " (" + args + ")"
then (situation A) works but (situation B) fails because oracle does not
understand this is a sp call
- if SP(my_sp, args) returns "BEGIN "my_sp + " (" + args + "); END;"
then (situation B) works but (situation A) fails because you can't have 2
semi columns (; in a statement.

Does anyone have any suggestions of how one could define SP so that it works
in both situations above (A and B)?

Many thanks in advance & Regards,

SerGioGioGio



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.