Skip to main content
vksrinu
Inspiring
April 9, 2008
Question

Result not returning Identity value.

  • April 9, 2008
  • 5 replies
  • 712 views
Hi,

I am using the CF8, and i am executing an insert statement to the SQL DB.
In that table i have a Identity column.
I am trying to display the newly inserted value from that table.
Presently I am using the query to fetch the new value.

By using the result in the cfquery i want to get this value. but its returning.
what will be the cause.

This topic has been closed for replies.

5 replies

Inspiring
April 11, 2008
BrianO wrote:
> where Generated_Keys is the key
>
> Why?

db/driver differences (my example was for sql server 2000), though the docs say
GENERATED_KEY is only for mysql.
Inspiring
April 11, 2008
I have CF8 & SQl Server 2005 and it has the following in the struct:
CACHED
EXECUTIONTIME
Generated_Keys
RECORDCOUNT
SQL

where Generated_Keys is the key

Why?
Inspiring
April 9, 2008
vkunirs wrote:
> I did the cfdump for the result, but it does not contain the identity value at all.

then either the table has no column w/identity or not cf8 or ...

this works as expected:

<cfquery datasource="lab" result="r">
INSERT a(testA)
VALUES ('a')
</cfquery>

<cfdump var="#r#">


dump results:
struct
CACHED false
EXECUTIONTIME 78
IDENTITYCOL 13062
RECORDCOUNT 1
SQL INSERT a(testA) VALUES ('a')

vksrinu
vksrinuAuthor
Inspiring
April 9, 2008
I did the cfdump for the result, but it does not contain the identity value at all.
Inspiring
April 9, 2008
do a cfdump of your query's result structure and make sure you are using
correct reference to the key holding your identity col value.
cfquery livedocs link:
http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Tags_p-q_17.html

posting the code that gives you trouble also helps...

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/