If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Insert ... Select ... Returning !!

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-19-03, 16:28
gringo43 gringo43 is offline
Registered User
 
Join Date: Nov 2003
Posts: 2
Red face Insert ... Select ... Returning !!

I have a JSP program that receives SQL UPDATE/INSERT/DELETE statements as text from other JSPs (for different tables of my DB) and this program has to perform a select on the updated data...

For INSERT statements, I tought of using PL/SQL's RETURNING clause to return the ROWID like that :

CallableStatement stmt = conn.prepareCall("BEGIN " + insertStatement + " RETURNING ROWID INTO ?; END;");
stmt.registerOutParameter(1, Types.VARCHAR);
stmt.executeUpdate();
rowId = stmt.getString(1);

It worked great with INSERT...VALUES(...) statements, but with an INSERT...SELECT statement, it fails because this could insert more than one row.

Is there a way of returning more than one ROWID, returning into an array or something... or maybe there's another approach I haven't tought of... ?

Thanks
Reply With Quote
  #2 (permalink)  
Old 11-20-03, 06:45
orababa@kshema orababa@kshema is offline
Registered User
 
Join Date: Nov 2003
Location: Bangalore,India
Posts: 51
1. Using Returning to could stop your program for not considering for heterogenous databases.
2. If it is purely oracle (in your case) avoid using returning to where it involves multiple fields
3. You could create collection for this...but is it you really need?
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On