Oracle, inserting date and time
-
Hi, I'm fairly new to SQL and am using Oracle SQL Developer. I have a table with a field of data type DATE. (It is the 3rd field along). I need to insert a date and time into the field. I have tried the following: INSERT INTO rentals VALUES (1, 7782, 02/02/2010 09:45:00,'PQ07JHG'); INSERT INTO rentals VALUES (1, 7782, TO_DATE(02/02/2010 09:45:00, 'dd-mm-yyyy' 'hh24:mm:ss'), 'PQ07JHG'); INSERT INTO rentals VALUES (1, 7782, TO_DATE(02/02/2010 09:45:00), 'PQ07JHG'); I keep on getting the same error: Bind variable "45" is NOT DECLARED. Thanks in advance for any help :)
-
Hi, I'm fairly new to SQL and am using Oracle SQL Developer. I have a table with a field of data type DATE. (It is the 3rd field along). I need to insert a date and time into the field. I have tried the following: INSERT INTO rentals VALUES (1, 7782, 02/02/2010 09:45:00,'PQ07JHG'); INSERT INTO rentals VALUES (1, 7782, TO_DATE(02/02/2010 09:45:00, 'dd-mm-yyyy' 'hh24:mm:ss'), 'PQ07JHG'); INSERT INTO rentals VALUES (1, 7782, TO_DATE(02/02/2010 09:45:00), 'PQ07JHG'); I keep on getting the same error: Bind variable "45" is NOT DECLARED. Thanks in advance for any help :)
What tool are you using to insert the data (application you are building or a management tool) it looks like a management tool so try:
INSERT INTO rentals VALUES (1, 7782, TO_DATE('02/02/2010 09:45:00'), 'PQ07JHG');
I do believe todate takes a string literal as the first parameter.
Never underestimate the power of human stupidity RAH
-
What tool are you using to insert the data (application you are building or a management tool) it looks like a management tool so try:
INSERT INTO rentals VALUES (1, 7782, TO_DATE('02/02/2010 09:45:00'), 'PQ07JHG');
I do believe todate takes a string literal as the first parameter.
Never underestimate the power of human stupidity RAH
The software I'm using is Oracle SQL Developer. I tried the above and got the error: "not a valid month". I also tried this (the only different from the original post is that I put '' around them) INSERT INTO rentals VALUES (1, 7782, to_date('02/02/2010 09:45:00', 'dd/mm/yyyy hh24:mm:ss'), 'PQ07JHG'); And with this effort, I got the error: "format code appears twice"
-
The software I'm using is Oracle SQL Developer. I tried the above and got the error: "not a valid month". I also tried this (the only different from the original post is that I put '' around them) INSERT INTO rentals VALUES (1, 7782, to_date('02/02/2010 09:45:00', 'dd/mm/yyyy hh24:mm:ss'), 'PQ07JHG'); And with this effort, I got the error: "format code appears twice"