LITERAL STRINGS

  • WHY DOESNT THIS WORK:

    SELECT C.CUS_PARENT,C.MACNUM,0 AS COUNT

    FROM CUST_FILE C

    WHERE C.CUS_DEACT_DATE = '2008-02-02';

    0 AS COUNT IS A LITERAL STRING I HAVE IN THE SELECT BUT THE QUERY FAILS TO EXECUTE GIVING ME A LITERAL STRING ERROR. I TRIED PUTING SINGLE QUOTES AROUND IT AND EVEN DOUBLE QUOTES BUT IT STILL DOES NOT WORK.

    DOES ANYONE HAVE A SUGGESTION?

    THANKS

  • are you sure the zero is causing the problem, it's alias? try SELECT 0 as CNT instead of the reserved word COUNT

    also, careful with the datefield...

    it's good practice to use the oracle TO_DATE function:

    .datefield=TO_DATE('04/14/2008',MM/DD/YYYY')

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • What is the exact error message you are getting?

    Is this query being run on SQL Server or ORACLE?

    I ran a similar query in the AdventureWorks database on my machine and it did not return an error. If on SQL Server I would recommend against using COUNT as a column name since it is an aggregate function.

  • THE ERROR I'M GETTING IS 'LITERAL DOES NOT MATCH FORMAT STRING' I AM RUNNING THIS ON ORACLE AND I CHANGED THE WORD COUNT TO CNT AND IT STILL DOES NOT WORK.

  • First, you might want to try asking your Oracle question on an Oracle forum... you'll usually get more correct answers that way... just a thought. 😉

    Second, Oracle requires you to convert your literal date string to a date using TO_DATE like Lowell suggested.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • THAT WORKED THANKS

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply