Solved

Coldfusion Last Inserted value in database

Posted on 2014-11-04
3
276 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
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 explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

910 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now