Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2010
    Posts
    15

    Unanswered: Less than sign (<) in db2cmd query

    Is there a problem with using the less than sign (<) in a query through db2cmd?

    I created a file, called oldstudies.bat, with the following SQL query

    Code:
    db2 select count(*) from central.studyattributes where studydate < '20071019'
    When I run oldstudies.bat out of db2cmd I get this

    Code:
    C:\>db2 select count(*) from central.studyattributes where studydate  0<'20071019'
    SQL0104N  An unexpected token "END-OF-STATEMENT" was found following "utes
    where studydate".  Expected tokens may include:  "<interval_qualifier>".
    SQLSTATE=42601
    Somehow a 0 got put in front of the less than sign. If I change the less than sign to equal, it runs fine.

    Code:
    C:\>oldstudies.bat
    
    C:\>db2 select count(*) from central.studyattributes where studydate = '20071019'
    
    1
    -----------
            177
    
      1 record(s) selected.
    Is there an escape character of some kind I need for the less than sign?

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    Certain characters, such as "<", ">", "|", "%" have special meaning to the Windows command shell -- this has nothing to do with DB2. Try enclosing your statement in double quotes.
    ---
    "It does not work" is not a valid problem statement.

  3. #3
    Join Date
    Apr 2008
    Posts
    39
    try to fire your query with double "". it should help

    db2 "select count(*) from central.studyattributes where studydate < '20071019'"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •