Link to home
Start Free TrialLog in
Avatar of Panos
PanosFlag for Germany

asked on

After insert pass the value from the primary key in session to the next page

Hello experts.
I have a table with 3 columns
art_ID (primary key)
test1
test2

Now with a query:
<cfquery datasource=#dsn#>
INSERT into test1,test2
VALUES ('#form.test1#','#form.test2#')
</cfquery>
<cflocation url="Detail.cfm">.
To get the values in the detailpage i need to get the art_ID value from the that insert


ASKER CERTIFIED SOLUTION
Avatar of adobe116
adobe116

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of adobe116
adobe116

sorry, when i said "developing a component," I meant a component that other developers could use... something you would post for download for instance that has to be DB independent.
Avatar of Panos

ASKER

Is this working in MySQL too.
Can i make the insert, and on the same page get the art_id that was generated and than pass this with a session to the next page?
Avatar of Panos

ASKER

Thank you for your help.
regards
Panos
the full code for mySQL would be (note the last line of the cfquery):

<cfquery name="insertTest" datasource=#dsn#>
INSERT into test1,test2
VALUES ('#form.test1#','#form.test2#');
SELECT last_insert_id() AS newID
</cfquery>

then you would do:
<cfset session.variableName = insertTest.newID />
if you wanted it in a session.