GnegDevelop
Programmer
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="#request.main_dsn#" name="lockTables">
LOCK TABLES member WRITE, user WRITE
</cfquery>
<!-- Insert member -->
<cfquery datasource="#request.main_dsn#" name="insertcust">
INSERT INTO member(
FirstName,
LastName,
Email,
member_type_fk
)
VALUES( '#form.firstname#',
'#form.lastname#',
'#form.email#',
1
)
</cfquery>
<!--- Insert new username --->
<cfquery datasource="#request.main_dsn#" name="insertUser">
INSERT INTO User( UserName, Password, cust_fk )
VALUES( '#form.Login#',
'#form.Password#',
LAST_INSERT_ID() )
</cfquery>
<!--- UNLOCK the table --->
<cfquery datasource="#request.main_dsn#" name="unlockTables">
UNLOCK TABLES
</cfquery>
<!--- LOCK the table --->
<cfquery datasource="#request.main_dsn#" name="lockTables">
LOCK TABLES member WRITE, user WRITE
</cfquery>
<!-- Insert member -->
<cfquery datasource="#request.main_dsn#" name="insertcust">
INSERT INTO member(
FirstName,
LastName,
Email,
member_type_fk
)
VALUES( '#form.firstname#',
'#form.lastname#',
'#form.email#',
1
)
</cfquery>
<!--- Insert new username --->
<cfquery datasource="#request.main_dsn#" name="insertUser">
INSERT INTO User( UserName, Password, cust_fk )
VALUES( '#form.Login#',
'#form.Password#',
LAST_INSERT_ID() )
</cfquery>
<!--- UNLOCK the table --->
<cfquery datasource="#request.main_dsn#" name="unlockTables">
UNLOCK TABLES
</cfquery>