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 > Delphi, C etc > insert and select in one statement

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-11-03, 00:28
khurramanis khurramanis is offline
Registered User
 
Join Date: Nov 2003
Location: Lahore, Pakistan
Posts: 5
Question insert and select in one statement

using MS Sql server and VB i can execute two queries Insert and select in one statement e.g. (insert into (....) values (...) Select @@Identity).
how can i do the same thing using Oracle and VB. ???
It gives error. here's what i want to do.
(insert into table1 (...) values (...) Select table1_sequence.currval from dual )

Khurram
Reply With Quote
  #2 (permalink)  
Old 11-18-03, 15:43
jora jora is offline
Registered User
 
Join Date: Dec 2002
Location: Antwerp, Belgium
Posts: 227
i would create a stored procedure in which a declare a variable, lets say vID and then assign it the value of table1_sequence.nextval. Then use the value of vID in your insert statement.
If you don't use the vID value besides the insert, you can also use the table1_sequence.nextval directly in your sql statement:

Code:
insert into 
table1(col1)
values(table1_sequence.nextval)
If you get the table1_sequence after the insert, you are not sure if it's the correct value, because another insert can already have been done.
__________________
Johan

Last edited by jora; 11-18-03 at 17:09.
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