Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert Into Returning 1

Status
Not open for further replies.

JonAustin1905

Programmer
Feb 6, 2004
21
US
Hi,
I've inherited an app riddled with

insert into x.

select max(id) from X

insert maxid into Y...


I'm looking to execute inserts into Oracle, returning the ID, using

"Insert into <table> (<cols>) values(<vals>) returning ID into <cfqueryparam...>"

Although it doesn't seem to allow me to do that..

has anyone done that in CF code?

TIA!

~ Jon
 
You should be able to return the identity from the database. (Sorry I'm MSSQL-centric, so I don't know the specific word for the identity). So anyway, for example in MSSQL we would put a statement at the end of the procedure, immediately after the insert, "SELECT SCOPE_IDENTITY as NewRecID" and that would return the ID to the query request.

YMMV with Oracle, but I'm sure there's a way to do that.

Phil Hegedusich
Senior Web Developer
IIMAK
-----------
A priest, a lawyer, and a rabbi walk into a bar. The bartender looks up and says "What is this, a joke?
 
A short google for:
oracle, getting, inserted, record

gave me this

Its the best I could find... Seems last row is a weakness of oracle.

ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
Smooth, Rudy, thanks for the clarification!

Phil Hegedusich
Senior Web Developer
IIMAK
-----------
A priest, a lawyer, and a rabbi walk into a bar. The bartender looks up and says "What is this, a joke?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top