SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 4 of 4

Thread: SQL Statement

  1. #1
    Senior Member
    Join Date
    May 2001
    Posts
    265
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    SQL Statement

    I am using 3.02 and never used any db tester functions before there is a sql statment I need to excute using DB_ExecuteSQL can someone please correct it.

    Basically what do I need to do about these quotes?

    here is the statment.
    select COBJECTNAME from TD_CHECK_DEFS WHERE cScript LIKE "%JOIN%" or cscript like "%(SELECT%" OR cscript LIKE "%COUNT(%" OR cscript LIKE "%EXISTS%" or cscript like "%( SELECT%"

  2. #2
    Senior Member
    Join Date
    Aug 1999
    Location
    Cambridge, UK
    Posts
    470
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: SQL Statement

    It might depend on the database you're accessing, but I think you should be using single-quotes around string values.

  3. #3
    Senior Member
    Join Date
    Jul 1999
    Location
    Bellingham, WA USA
    Posts
    1,323
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: SQL Statement

    Also check case on cScript vs cscript.

  4. #4
    Super Member
    Join Date
    Jul 2003
    Location
    Boulder, CO
    Posts
    1,276
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: SQL Statement

    For double quotes:

    Use "" in your strings (kinda like \").

    I use both singles (') and doubles (") depending upon what type of string i need. For db's I use mysql and I don't think double quotes are ever required, but some of the vbs-scripts that I generate from silk need the " so I use "".

    Also, with a really long query like that, I recommend that you build up your string before passing it into DB_ExecuteSQL.

    For example:

    STRING sqlStr
    sqlSTR = "select COBJECTNAME from TD_CHECK_DEFS WHERE cScript LIKE"
    sqlSTR += """";
    sqlSTR += "%JOIN%"

    etc.

    use:
    Print (sqlSTR)
    to debug your statment.

    Ideally, use the statement output by Print elsewhere to see if the db really likes the syntax.

    Chris
    Chris R Mead

    The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 9.38%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 05:04 PM.

Copyright BetaSoft Inc.