Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

CFQUERY - SELECT works, DELETE gives attribute error

New Here ,
Dec 06, 2009 Dec 06, 2009

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>

461
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 06, 2009 Dec 06, 2009

You can only output select queries.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 06, 2009 Dec 06, 2009
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Dec 06, 2009 Dec 06, 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources