I am fairly new to flex. So please bear with me no this
question.
I would like to get MYSQL ID of the last record I inserted.
MSQL has as function LAST_INSERT_ID() that is connection based and
will return the last id of the last inserted record. My thought was
in the function contained within the cfc to do 2 queries insert the
record and return the last id directly after (see below). However,
I don't know how I would read the results back into flex. I am
unsure how to write the event handler. Thanks
<cffunction name="insertUser" access="remote"
returntype="query" >
<cfargument name="SSN" required="false" type="string"
hint="SSN"/>
<cfargument name="FNAME" required="false" type="string"
hint="FNAME"/>
<cfargument name="LNAME" required="false" type="string"
hint="LNAME"/>
<cfargument name="CLIENTID" required="false"
type="string" hint="NEW CLIENTID"/>
<cfquery name="insUser" datasource="DBT">
INSERT INTO CLIENT (SSN, FNAME, LNAME) VALUES (
<cfqueryparam value="#ARGUMENTS.SSN#"
cfsqltype="CF_SQL_VARCHAR" maxlength="12"/>,
<cfqueryparam value="#ARGUMENTS.FNAME#"
cfsqltype="CF_SQL_VARCHAR" maxlength="20"/>,
<cfqueryparam value="#ARGUMENTS.LNAME#"
cfsqltype="CF_SQL_VARCHAR" maxlength="30"/>)
</cfquery>
<cfquery name="qRead" datasource="DBT">
SELECT last_insert_id() AS CLIENTID
</cfquery>
<cfreturn qRead >
</cffunction>