mySQL question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Caspah
    Confirmed User
    • Oct 2003
    • 251

    #1

    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.
    FreeTicketCash - Everyone likes to signup for a free ticket, wide variety of free e-mail sites!
    DatingGold - 1$ per email dating site, also per signup.
  • icedemon
    Confirmed User
    • Jun 2003
    • 1022

    #2
    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.
    Clips4Sale.com

    Comment

    • Caspah
      Confirmed User
      • Oct 2003
      • 251

      #3
      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.
      FreeTicketCash - Everyone likes to signup for a free ticket, wide variety of free e-mail sites!
      DatingGold - 1$ per email dating site, also per signup.

      Comment

      • NetRodent
        Confirmed User
        • Jan 2002
        • 3985

        #4
        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).
        "Every normal man must be tempted, at times, to spit on his hands, hoist the black flag, and begin slitting throats."
        --H.L. Mencken

        Comment

        • Lane
          Will code for food...
          • Apr 2001
          • 8496

          #5
          switch to mysql
          what u're using is Oracle ?

          Comment

          • TEK9
            Registered User
            • Nov 2003
            • 3

            #6
            Originally posted by Caspah
            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.

            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.

            Comment

            • sweet7
              Confirmed User
              • May 2003
              • 1792

              #7
              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
              ICQ: 282814268

              Comment

              • Caspah
                Confirmed User
                • Oct 2003
                • 251

                #8
                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..
                FreeTicketCash - Everyone likes to signup for a free ticket, wide variety of free e-mail sites!
                DatingGold - 1$ per email dating site, also per signup.

                Comment

                • TEK9
                  Registered User
                  • Nov 2003
                  • 3

                  #9
                  you're never gonna get anywhere until you tell it what columns to put the values in

                  Comment

                  • Caspah
                    Confirmed User
                    • Oct 2003
                    • 251

                    #10
                    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.
                    FreeTicketCash - Everyone likes to signup for a free ticket, wide variety of free e-mail sites!
                    DatingGold - 1$ per email dating site, also per signup.

                    Comment

                    • TEK9
                      Registered User
                      • Nov 2003
                      • 3

                      #11
                      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')

                      Comment

                      • Caspah
                        Confirmed User
                        • Oct 2003
                        • 251

                        #12
                        Thanks for the help guys
                        FreeTicketCash - Everyone likes to signup for a free ticket, wide variety of free e-mail sites!
                        DatingGold - 1$ per email dating site, also per signup.

                        Comment

                        Working...