Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

LOCK TABLE with ColdFusion Front

Status
Not open for further replies.

GnegDevelop

Programmer
Jul 2, 2003
4
US
I am running MySQL in junction with Cold Fusion on a Windows 2000 platform. In order to create an enviroment that assures that an INSERT followed by a SELECT will return the last created ID, I used a LOCK TABLE statement but now the server always returns that table as locked. I tried to run an UNLOCK TABLES command but it still returns the table as locked when I check the status of the thread. I reloaded the service and could again select from the table but again when I ran the code below the same problem occured. Please HELP!


<!--- LOCK the table --->
<cfquery datasource=&quot;#request.main_dsn#&quot; name=&quot;lockTables&quot;>
LOCK TABLES member WRITE, user WRITE
</cfquery>

<!-- Insert member -->
<cfquery datasource=&quot;#request.main_dsn#&quot; name=&quot;insertcust&quot;>
INSERT INTO member(
FirstName,
LastName,
Email,
member_type_fk
)
VALUES( '#form.firstname#',
'#form.lastname#',
'#form.email#',
1
)
</cfquery>

<!--- Insert new username --->
<cfquery datasource=&quot;#request.main_dsn#&quot; name=&quot;insertUser&quot;>
INSERT INTO User( UserName, Password, cust_fk )
VALUES( '#form.Login#',
'#form.Password#',
LAST_INSERT_ID() )
</cfquery>

<!--- UNLOCK the table --->
<cfquery datasource=&quot;#request.main_dsn#&quot; name=&quot;unlockTables&quot;>
UNLOCK TABLES
</cfquery>
 
I've gotten rid of the LOCK TABLES but when I try to run the LAST_INSERT_ID through a <cfquery> I get a SYNTAX error. Can I use the LAST_INSERT_ID function with cold fusion?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top