November 22, 2009 at 1:38 pm
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.
November 24, 2009 at 9:29 am
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 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy