problem with delete statment

Discussion in 'Programming' started by unitedlocalbands, Sep 25, 2007.

  1. #1
    Check out this statment

    
    DELETE 
    FROM USER_MAIL_DELETE
    WHERE MAILID IN ('#form.mailid#') 
    
    Code (markup):
    When I run this statment it looks like this in the debug:

    
    DELETE 
    FROM USER_MAIL_DELETE
    WHERE MAILID IN ('35E1432A-A92B-4A27-A8660015ED9540C6,35E0E7EB-F32F-82E7-F054FC7F8A04C420') 
    
    Code (markup):
    The delimiter quotes are only showing up at the very ends. I cant figure out how to get them to show up around every "mailid"

    I'm trying to use a simple form from another page that contains a checkbox list where the user can select which record they would like to delete. This statment will delete a single record at a time but when I select mutiple records the delete statment wont work because of where the quotes are showing up.

    I ran the sql statment like this:

    
    DELETE 
    FROM USER_MAIL_DELETE
    WHERE MAILID IN ('35E1432A-A92B-4A27-A8660015ED9540C6', '35E0E7EB-F32F-82E7-F054FC7F8A04C420') 
    
    Code (markup):
    With the qoutes in the correct spots and it worked fine.

    Thanks for the help!
     
    unitedlocalbands, Sep 25, 2007 IP
  2. cfStarlight

    cfStarlight Peon

    Messages:
    398
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    The simplest way is to use cfqueryparam with "list". Here is an untested example.

    
    <cfparam name="form.mailid" default="">
    <cfif listLen(form.mailId) gt 0>
       <cfquery ...>
         DELETE 
         FROM USER_MAIL_DELETE
         WHERE MAILID IN 
            (
            <!--- or whatever the correct type is for your db --->
           <cfqueryparam value="#form.mailid#" cfsqltype="cf_sql_varchar" list="true">
            )
       </cfquery>
    </cfif>
    
    Code (markup):
     
    cfStarlight, Sep 26, 2007 IP