Solved

Coldfusion Last Inserted value in database

Posted on 2014-11-04
3
320 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 77

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

Increase Agility with Enabled Toolchains

Connect your existing build, deployment, management, monitoring, and collaboration platforms. From Puppet to Chef, HipChat to Slack, ServiceNow to JIRA, Splunk to New Relic and beyond, hand off data between systems to engage the right people.

Connect with xMatters.

Question has a verified solution.

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

Recently while working on a project I got a very annoying cfdocument has no body error message. I had never seen this error before. So I checked the code. The code was pretty simple; it was Just showing me the cfdocumnt tag and inside that tag a …
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database

717 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