3 Replies Latest reply on Apr 10, 2012 9:43 PM by Sc0tt

    ORA-00917: missing comma

    928281
      Hello again,

      I am here because I know I am missing something. I see I have a comma after every column name in the INSERT clause, and in the VALUES clause I put commas after the values for the corresponding columns.

      Even if you don't tell me the exact reason, I'd appreciate any guidance to find out where my syntax is wrong.

      Here is my code:

      INSERT INTO appeals (appeal_id, crime_id, status, TO_CHAR(filing_date, 'MONTH DD YYYY')"Filing_Date",
      TO_CHAR(hearing_date, 'MONTH DD YYYY')"Hearing_Date")
      VALUES(APPEALS_ID_SEQ.NEXTVAL, :crime_id, '', :filing_date, :hearing_date);

      Thanks!
        • 1. Re: ORA-00917: missing comma
          Sc0tt
          Your syntax is wrong - it goes:
          insert into <table>[(columnlist)]
          values([valuelist])
          You are putting the to_char in the wrong spot. You can't put it in the column list - it needs to go in the values list. And to enter data into a date column, you want to_date. You want to convert a character string into its date representation.

          Like
          insert into table (co1, col2, col3)
          values('ABC', to_date(:someval, 'DD/MM/YYYY'), to_date(:otherval, 'DD/MM/YYYY'))
          1 person found this helpful
          • 2. Re: ORA-00917: missing comma
            928281
            Sc0tt,

            Thank you so much. While doing a assement test on my chapter, I realized that I was suppose to use the TO_DATE function.

            But I do wanna ask, just out of curiosity, why did it say 'missing comma' instead of 'incorrect syntax'?
            • 3. Re: ORA-00917: missing comma
              Sc0tt
              The parser is unfortunately not always 100% helpful. Most likely it saw the first ( in your to_char and was expecting a field to be in there. I'd have to run it to see which line it is pointing to be sure - either way, no functions in the column list are accepted.

              Glad it helped!