Solved

Need help with a SQL query error: probably me being stupid

Posted on 2007-03-27
4
144 Views
Last Modified: 2013-12-24
Hello All,

      I apologize in advance if this is really dumb; but coldfusion is giving me an error when i try to run the following delete query:

                              DELETE FROM FWjobs
                        WHERE title IN '#form.jobs#'
                        AND subcatText IN '#form.subcategories#'
                        AND catID IN '#form.categories#'
       
All the error says is incorrect syntax.  The stack trace shows the statement was evaluated at runtime as the following:

                               DELETE FROM FWjobs
                               WHERE title IN 'Delivery Person,Packer Person'
                               AND subcatText IN 'Delivery,Shipper'
                               AND catID IN '2,3'

Which looks correct to me; am I doing something stupid?

Thank you.
0
Comment
Question by:andrewaiello
  • 2
  • 2
4 Comments
 
LVL 21

Accepted Solution

by:
ziolko earned 125 total points
ID: 18801948
should look like this:
DELETE FROM FWjobs
WHERE title IN ('Delivery Person','Packer Person')
AND subcatText IN ('Delivery','Shipper')
AND catID IN (2,3)

ziolko.
0
 
LVL 1

Author Comment

by:andrewaiello
ID: 18802477
so the parentheses are missing.... those lists are coming in from the forms multiple selection list box...how can i change that?
0
 
LVL 1

Author Comment

by:andrewaiello
ID: 18802486
and also; the error only flagged on the last line of that query; if the parenthesis where the error..wouldn't the previous lines have been flagged?
0
 
LVL 21

Expert Comment

by:ziolko
ID: 18806423
error is only on last line (AND catID IN '2,3') because catId is of type int while '2,3' is treated as string.
theres no error in: AND subcatText IN 'Delivery,Shipper' because subcatText and 'Delivery,Shipper' are same type, but in this form 'Delivery, Shipper' will be treated as set containing just one string that is: 'Delivery,Shipper' and ('Delivery', 'Shipper') is set containg two strings

ziolko.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now