Insert statement with subsititutin variables and To_date

  • I am trying to use a substitution variable with a to_date in a insert statement but I keep getting a "missing comma" error. I am not sure if this is written the correct way to accomplish this or if I am just missing something. The statement looks like this.

    INSERT INTO EMPLOYEE ( EMP_ID, START_DATE, END_DATE )

    VALUES ('&EMP_ID', TO_DATE( '&START_DATE','12 17 2009','MM DD YYYY'), TO_DATE('&END_DATE','12 17 2009','MM DD YYYY');

    I have also tried it this way

    INSERT INTO EMPLOYEE ( EMP_ID, START_DATE, END_DATE )

    VALUES ('&EMP_ID', '&START_DATE', TO_DATE('12 17 2009','MM DD YYYY'), '&END_DATE', TO_DATE('12 17 2009','MM DD YYYY');

    Your help is greatly appreciated.

  • Ok sometimes you just need to go to sleep and wake up and the obvious will appear. Below is the proper way to write this.

    INSERT INTO EMPLOYEE ( EMP_ID, START_DATE, END_DATE )

    VALUES ('&EMP_ID', TO_DATE( '&START_DATE','MM DD YYYY'), TO_DATE('&END_DATE','MM DD YYYY'));

Viewing 2 posts - 1 through 1 (of 1 total)

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