Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Result not returning Identity value.

Participant ,
Apr 09, 2008 Apr 09, 2008
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.

TOPICS
Database access
689
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 09, 2008 Apr 09, 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/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 09, 2008 Apr 09, 2008
I did the cfdump for the result, but it does not contain the identity value at all.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 09, 2008 Apr 09, 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')

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 10, 2008 Apr 10, 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?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 10, 2008 Apr 10, 2008
LATEST
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.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources