By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,983 Members | 2,082 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,983 IT Pros & Developers. It's quick & easy.

inserting data in time field

priyan
P: 54
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.
Expand|Select|Wrap|Line Numbers
  1. CREATE TABLE blah
  2. (
  3.   uuid integer NOT NULL DEFAULT nextval('universal_sq'::regclass),
  4.   "time" timestamp without time zone
  5. WITHOUT OIDS;
  6.  
insert query:
Expand|Select|Wrap|Line Numbers
  1. insert into blah (uuid,time)values (5,'')
  2.  
I am getting an error like this:

Expand|Select|Wrap|Line Numbers
  1. ERROR: invalid input syntax for type timestamp: ""
  2. SQL state: 22007
  3.  
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.....
Aug 10 '07 #1
Share this Question
Share on Google+
4 Replies


Expert 100+
P: 534
... ... ...
Expand|Select|Wrap|Line Numbers
  1. CREATE TABLE blah
  2. (
  3.   uuid integer NOT NULL DEFAULT nextval('universal_sq'::regclass),
  4.   "time" timestamp without time zone
  5. WITHOUT OIDS;
  6.  
insert query:
Expand|Select|Wrap|Line Numbers
  1. insert into blah (uuid,time)values (5,'')
  2.  
I am getting an error like this:
Expand|Select|Wrap|Line Numbers
  1. ERROR: invalid input syntax for type timestamp: ""
  2. SQL state: 22007
  3.  
... ... ...
Either one of these two statements should work for you:
Expand|Select|Wrap|Line Numbers
  1. insert into blah (uuid,time) values (5, NULL);
  2. insert into blah (uuid) values (5);
  3.  
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.
Aug 10 '07 #2

priyan
P: 54
Either one of these two statements should work for you:
Expand|Select|Wrap|Line Numbers
  1. insert into blah (uuid,time) values (5, NULL);
  2. insert into blah (uuid) values (5);
  3.  
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
Aug 11 '07 #3

gauravgmbhr
100+
P: 107
thank you for helping me

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

Both works


Regards Gaurav
Aug 11 '07 #4

priyan
P: 54
U can also use Values (5,Default) instead of values (5,NULL)

Both works


Regards Gaurav

Thank you very much helping me..
Aug 14 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.