![]() |
mySQL question
i have a question for anyone that knows sql cuz im a noob...
SQL> INSERT INTO IS_QUALIFIED 2 VALUES (1234, 'ISM 1234','1988-09-09'); VALUES (1234, 'ISM 1234','1988-09-09') * ERROR at line 2: ORA-01861: literal does not match format string How can i fix this error with inserting the date as a value? I appreciate any help anyone can give.:thumbsup :thumbsup |
What is that "2" on the 2nd line. It should be something like this
INSERT INTO IS_QUALIFIED VALUES (1234, 'ISM 1234','1988-09-09'); I hope your not using spaces in your table names. |
If you mean by spaces in my tables as the IS_QUALIFIED...spaces where the underscore is? No, I have underscores. That 2 was there because i pressed enter and did it on the second line. How would I format the date so I can just use a month and year. Every time I try it like that it says the wrong format. Thanks for whatever info someone can let me know. :thumbsup
|
I'm guessing your table is set to the "date" column expects a "date". If you want to do just years and months either change it to a "char" column. You may be better of keeping the date format but just ignoring the day (always use 01).
|
switch to mysql :glugglug
what u're using is Oracle ? |
Quote:
the problem is you haven't told it what columns to put the values in. It should look like this: INSERT INTO IS_QUALIFIED (name, of, each, column) VALUES (1234, 'ISM 1234','1988-09-09'); the names of each column should come in the first set of parentheses (don't forget the commas), and then the proper values in the SAME ORDER come in the second set of parentheses. |
Tek 9 has a point but it doesn't need to be specified unless you're re-arranging the order of the fields or leaving some fields out altogether.
Do what netrodent said if you want the date but not necessarily in the mysql format then use regular char types for your fields. A little reading never hurt anybody |
Still getting the same error...
Table command: CREATE TABLE IS_QUALIFIED (FACULTY_ID INTEGER NOT NULL, COURSE_ID VARCHAR2(8) NOT NULL, DATE_QUALIFIED VARCHAR2(10) NOT NULL, CONSTRAINT IS_QUALIFIED_PK PRIMARY KEY (FACULTY_ID, COURSE_ID), CONSTRAINT IS_QUALIFIED_FK FOREIGN KEY (FACULTY_ID) REFERENCES FACULTY (FACULTY_ID), CONSTRAINT IS_QUALIFIED_FK2 FOREIGN KEY (COURSE_ID) REFERENCES COURSE (COURSE_ID)); Load command: INSERT INTO IS_QUALIFIED VALUES (2143, 'ISM 3112', '1988-09-01'); INSERT INTO IS_QUALIFIED VALUES (2143, 'ISM 3113', '1988-09-01'); INSERT INTO IS_QUALIFIED VALUES (3487, 'ISM 4212', '1995-09-01'); INSERT INTO IS_QUALIFIED VALUES (3487, 'ISM 4930', '1996-09-01'); INSERT INTO IS_QUALIFIED VALUES (4756, 'ISM 3113', '1991-09-01'); INSERT INTO IS_QUALIFIED VALUES (4756, 'ISM 3112', '1991-09-01'); they are all in the correct order also.. |
you're never gonna get anywhere until you tell it what columns to put the values in
|
INSERT INTO IS_QUALIFIED(FACULTY_ID, COURSE_ID, DATE_QUALIFIED)
VALUES (2143, 'ISM 3112', '1988-09-01'); ^^^i tried that also and it still didnt work. |
i dunno then. you might want to change the column for the date back into the DATE format, and use the TO_DATE command when you format the value:
TO_DATE('1988-09-01', 'yyyy-Mon-dd') |
Thanks for the help guys
|
| All times are GMT -7. The time now is 02:30 PM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2026, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123