Skip to main content
Participant
December 6, 2009
Question

CFQUERY - SELECT works, DELETE gives attribute error

  • December 6, 2009
  • 2 replies
  • 492 views

Anyone know how to fix this problem?

This works...

<cfquery name="deleteNote" datasource="notes">
SELE
</cfquery>

<cfoutput query="deleteNote">Deleted note...</cfoutput>

The query works but an error message appears on the screen...

<cfquery name="deleteNote" datasource="notes">
DELETE FROM tblNotes
</cfquery>

<cfoutput query="deleteNote">Deleted note...</cfoutput>

Attribute validation error for tag cfoutput.

The value of the attribute query, which is currently deleteNote, is invalid.
The error occurred in C:\Inetpub\wwwroot\cf\notes2.cfm: line 20
18 :      
19 :      
20 : <cfoutput query="deleteNote"></cfoutput>

    This topic has been closed for replies.

    2 replies

    Inspiring
    December 7, 2009

    <cfquery name="deleteNote" datasource="notes">

    DELETE FROM tblNotes

    </cfquery>

    <cfoutput query="deleteNote">Deleted

    note...</cfoutput>

    1. DELETE queries do not typically return results. So what information are you trying to display in the cfoutput?

    2. Both cfquery's have the same name. So if you are attempting to use both in the same page, the second query (ie DELETE) will overwrite the results of first. Resulting in an error when you try and output the results, because there are none for DELETE statements.

    If you wish to preserve the results of first SELECT query, give the cfquery's different names:

    ... #Columns# ....

    </cfoutput

    Inspiring
    December 6, 2009

    You can only output select queries.

    Participant
    December 7, 2009

    Thank you.  That guided me to my answer.  I was under the impression that CFQUERY tags were not executed until they were called by a CFOUTPUT, but I realize my error now.