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!

Splitting multiple (pl/sql)/sql statements

955512Oct 29 2012 — edited Oct 30 2012
Hi,

I am trying to build a pl/sql editor on my website. Everything works fine for single commands, but the way it is going to be used the user can enter multiple commands/blocks on the text editor to execute and in which case the OracleCommand throws an error. I know I can wrap the multiple commands in a block but when I do an ExecuteNonQuery it returns -1 instead of how many rows are changed. For example, the following commands could be entered:

INSERT INTO someTable(col1, col2, col3) VALUES (val1, val2, val3);

INSERT INTO someTable(col1, col2, col3) VALUES (val4, val5, val6);

BEGIN

do something;

END;

/

And when the user clicks run I have two choices that I know of. I could wrap all the text in BEGIN and END; but as stated above it then does not return the correct row count, or I could try and split up the commands/blocks, which looks like thats what I'm going to have to do. So my question is is there an easy way, or hard anyway, to split multiple statements into individual statements? What is really giving me the problems are the annonymous blocks, so if there is an easy what to tell when an annonymous block is complete that would be very helpful.

Thanks in advance
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 27 2012
Added on Oct 29 2012
4 comments
1,423 views