inserting data in time field

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • priyan
    New Member
    • Aug 2007
    • 54

    inserting data in time field

    hai everyone,
    I am having a doubt in inserting data in time field.
    I am having a table in which in column in timestamp without time zone datatype. I want to insert a row into the table but that time field has no value if I insert omitting that column error occurs...
    for eg.
    [code=sql]
    CREATE TABLE blah
    (
    uuid integer NOT NULL DEFAULT nextval('univer sal_sq'::regcla ss),
    "time" timestamp without time zone
    )
    WITHOUT OIDS;
    [/code]
    insert query:
    [code=sql]
    insert into blah (uuid,time)valu es (5,'')
    [/code]

    I am getting an error like this:

    [code=text]
    ERROR: invalid input syntax for type timestamp: ""
    SQL state: 22007
    [/code]

    Please help me i should have that column name in the list but should not have an value for that column.please tell me is there any possible way for this. please help me as soon as possible.....
    Last edited by priyan; Aug 10 '07, 08:13 AM. Reason: to change the title
  • michaelb
    Recognized Expert Contributor
    • Nov 2006
    • 534

    #2
    Originally posted by priyan
    ... ... ...
    [code=sql]
    CREATE TABLE blah
    (
    uuid integer NOT NULL DEFAULT nextval('univer sal_sq'::regcla ss),
    "time" timestamp without time zone
    )
    WITHOUT OIDS;
    [/code]
    insert query:
    [code=sql]
    insert into blah (uuid,time)valu es (5,'')
    [/code]
    I am getting an error like this:
    [code=text]
    ERROR: invalid input syntax for type timestamp: ""
    SQL state: 22007
    [/code]
    ... ... ...
    Either one of these two statements should work for you:
    [CODE=sql]
    insert into blah (uuid,time) values (5, NULL);
    insert into blah (uuid) values (5);
    [/CODE]

    Did you see the manual page for INSERT command?

    You probably realize that outside of this example there's no need to provide a value for the SERIAL field uuid.

    Comment

    • priyan
      New Member
      • Aug 2007
      • 54

      #3
      Originally posted by michaelb
      Either one of these two statements should work for you:
      [CODE=sql]
      insert into blah (uuid,time) values (5, NULL);
      insert into blah (uuid) values (5);
      [/CODE]

      Did you see the manual page for INSERT command?

      You probably realize that outside of this example there's no need to provide a value for the SERIAL field uuid.
      thank you for helping me

      Comment

      • gauravgmbhr
        New Member
        • Feb 2007
        • 107

        #4
        Originally posted by priyan
        thank you for helping me

        U can also use Values (5,Default) instead of values (5,NULL)

        Both works


        Regards Gaurav

        Comment

        • priyan
          New Member
          • Aug 2007
          • 54

          #5
          Originally posted by gauravgmbhr
          U can also use Values (5,Default) instead of values (5,NULL)

          Both works


          Regards Gaurav

          Thank you very much helping me..

          Comment

          Working...