Solved

Coldfusion Last Inserted value in database

Posted on 2014-11-04
3
284 Views
Last Modified: 2014-11-05
Is there any function in coldfusion, i want last inserted value from database.
if there is no function so what is the right way to do it.

database could be oracle or MSSQL

Thank you.....
0
Comment
Question by:xeondxb
3 Comments
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
ID: 40423230
I don't believe Coldfusion is much more than an interface to a database.  It only remembers/tracks what you tell it to.

Unless you return the value from the database, I don;t think it has any 'smarts' built in.

An example:
Oracle has a 'returning' clause hat allows you to return specific values from DML.  If the app coded the DML to take advantage of the returning clause and handled the return values properly, then yes.

If not, I'm afraid you might be out of luck.

Then again, I'm not a Coldfusion expert...
0
 
LVL 52

Accepted Solution

by:
_agx_ earned 500 total points
ID: 40423292
EDIT:

I don't use Oracle, but for SQL Server table's that have an IDENTITY column, you can use cfquery's "result" attribute to return the new record ID from an INSERT.

       <cfquery name="addRecord" result="yourResult" ...>
              INSERT INTO SomeTable (..Columns..) VALUES ( ... values ...)
       </cfquery>

        The new identity value is <cfoutput>#yourResult.IDENTITYCOL#</cfoutput>

The exact syntax is db dependent. For Oracle, try the ROWID value. For more details see the cfquery docs.
0
 

Author Closing Comment

by:xeondxb
ID: 40424824
Thanks
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I spent nearly three days trying to figure out how incorporate OAuth in Coldfusion for the Eventful API. Hopefully, this article will allow Coldfusion Programmers to buzz through the API when they need to. Basically, what this script does is authori…
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question