Nemetona
asked on
strange behaviour in coldfusion - can anyone shed light
I am using Coldfusion MX code to update some MS Access database tables.
I have written some code which checks to see if a record exists in a table and if it does then it deletes it.
What is happening is that the check confirms that the record exists but I then get an error message telling me that the record has been deleted when I try to delete it.
I have attached the code I use and a screenshot of the results.
Can anyone explain to me what is happening and how I can fix it.
<cfoutput>Status = 0<br></cfoutput>
<cfoutput>Unit=All <br></cfoutput>
<cfquery name="getexistingsubidreco rd" datasource="#MM_datasource #">
SELECT * FROM SubmitAssessorAcceptance WHERE Subid=#thesub#;
</cfquery>
<cfif #getexistingsubidrecord.re cordcount# GT 0>
<cfdump var="#getexistingsubidreco rd#">
<cfoutput>Record already exists</cfoutput>
<cfquery datasource="#MM_datasource #">
DELETE SubmitAssessorAcceptance.* FROM SubmitAssessorAcceptance
WHERE Subid=#thesub#
</cfquery>
</cfif>
<cfoutput>Delete all</cfoutput>
Thanks
scr1.JPG
I have written some code which checks to see if a record exists in a table and if it does then it deletes it.
What is happening is that the check confirms that the record exists but I then get an error message telling me that the record has been deleted when I try to delete it.
I have attached the code I use and a screenshot of the results.
Can anyone explain to me what is happening and how I can fix it.
<cfoutput>Status = 0<br></cfoutput>
<cfoutput>Unit=All <br></cfoutput>
<cfquery name="getexistingsubidreco
SELECT * FROM SubmitAssessorAcceptance WHERE Subid=#thesub#;
</cfquery>
<cfif #getexistingsubidrecord.re
<cfdump var="#getexistingsubidreco
<cfoutput>Record already exists</cfoutput>
<cfquery datasource="#MM_datasource
DELETE SubmitAssessorAcceptance.*
WHERE Subid=#thesub#
</cfquery>
</cfif>
<cfoutput>Delete all</cfoutput>
Thanks
scr1.JPG
ASKER
I tried that variation but it made no difference to the result. I am still getting the "Record is Deleted" message.
Any other thoughts?
Any other thoughts?
It seems you may have some corruption, try the steps outlined here...
http://support.microsoft.com/?kbid=308630
http://support.microsoft.com/?kbid=308630
ASKER
I have already tried compacting and repairing the database. It made no difference. Any idea what else might cause queries to run twice?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
There are no problems with the database itself. I can update, insert and delete directly in the table and also from a query within MS Access.
I have also tried creating a different coldfusion page with just the most simple command on it but I am still getting the error.
Is there any signifigance to the fact that the Coldfuion is saying I have called the code twice or is this how it would normally appear?
D:\Inetpub\wwwroot\Testing Site\test1 .cfm: line 152
Called from D:\Inetpub\wwwroot\Testing Site\test1 .cfm: line 139
Called from D:\Inetpub\wwwroot\Testing Site\test1 .cfm: line 58
Called from D:\Inetpub\wwwroot\Testing Site\test1 .cfm: line 56
Called from D:\Inetpub\wwwroot\Testing Site\test1 .cfm: line 1
Called from D:\Inetpub\wwwroot\Testing Site\test1 .cfm: line 152
Called from D:\Inetpub\wwwroot\Testing Site\test1 .cfm: line 139
Called from D:\Inetpub\wwwroot\Testing Site\test1 .cfm: line 58
Called from D:\Inetpub\wwwroot\Testing Site\test1 .cfm: line 56
Called from D:\Inetpub\wwwroot\Testing Site\test1 .cfm: line 1
I have also tried creating a different coldfusion page with just the most simple command on it but I am still getting the error.
Is there any signifigance to the fact that the Coldfuion is saying I have called the code twice or is this how it would normally appear?
D:\Inetpub\wwwroot\Testing
Called from D:\Inetpub\wwwroot\Testing
Called from D:\Inetpub\wwwroot\Testing
Called from D:\Inetpub\wwwroot\Testing
Called from D:\Inetpub\wwwroot\Testing
Called from D:\Inetpub\wwwroot\Testing
Called from D:\Inetpub\wwwroot\Testing
Called from D:\Inetpub\wwwroot\Testing
Called from D:\Inetpub\wwwroot\Testing
Called from D:\Inetpub\wwwroot\Testing
Its hard to tell from the line numbers, I don't know what is at those lines or if they are inside of a loop? Is the code in your first post the entire code block?
> I have also tried creating a different coldfusion page with just the most simple command on it but I am still getting the error.
Good - did you try different record IDs and different tables? What gives the error and what conditions do not? Is it always there or just for a particular ID?
Oh, do you have any triggers or procedures in the database that run when a table is changed?
> I have also tried creating a different coldfusion page with just the most simple command on it but I am still getting the error.
Good - did you try different record IDs and different tables? What gives the error and what conditions do not? Is it always there or just for a particular ID?
Oh, do you have any triggers or procedures in the database that run when a table is changed?
I don't use Access either but a quick search turned up several articles that mention a bunch of reasons that error might occur. Access is a desktop db, so it's got some limitations enterprise db's don't.
Is this db also accessed by other users or are there any triggers involved? Have you ever been able to successfully delete records from this table or any other?
Is this db also accessed by other users or are there any triggers involved? Have you ever been able to successfully delete records from this table or any other?
Gah.. didn't see the other comment before hitting submit. Ignore my response, it's basically the same as what gd's asking.
ASKER
I can update the database from a different coldfusion page so I don't think the problem lies with the database.
The code does appear to be running my queries twice as at one point I have an insert query. I checked the database before running the code and the records do not exist, I run the code and I get an error message that the record already exists. When I check the database the records are now present.
When I put debugging statements into the code they do not appear to run more than once. Is there any way the query can run twice without the page being called twice?
The code does appear to be running my queries twice as at one point I have an insert query. I checked the database before running the code and the records do not exist, I run the code and I get an error message that the record already exists. When I check the database the records are now present.
When I put debugging statements into the code they do not appear to run more than once. Is there any way the query can run twice without the page being called twice?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
So what ended up being the problem? :)
DELETE FROM SubmitAssessorAcceptance WHERE Subid=#thesub#