If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > inserting null value to date field

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-12-03, 04:23
angelc angelc is offline
Registered User
 
Join Date: Nov 2003
Posts: 3
inserting null value to date field

Is there any way of setting NULL to nullable date field other than the following two.
1.Hard coding as NULL
2.Leaving the field name in the field list while inserting

I am looking for something like converting from a string etc....


Can anyone help me?????????????????????/
Reply With Quote
  #2 (permalink)  
Old 12-12-03, 09:03
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
If you are inserting the row there are two ways:

INSERT into my table (Col1,col2,ColDate) values (1,2,NULL)
INSERT into mytable (col1,col2) values (1,2)

First one explicitly sets it to null while the second implicitly sets it to null (if no default value has been specified for the date column).

For updating, you must explicitly set it to NULL.

HTH

Andy
Reply With Quote
  #3 (permalink)  
Old 12-12-03, 10:54
jsander jsander is offline
Registered User
 
Join Date: Apr 2003
Posts: 191
Hi,

NULLIF *may* be your friend:

INSERT into my table( ..., coldate) values (..., NULLIF('0', YOURCOLUMN) )

should insert a NULL if YOURCOLUMN happens to be '0'.

Johann

Quote:
Originally posted by ARWinner
If you are inserting the row there are two ways:

INSERT into my table (Col1,col2,ColDate) values (1,2,NULL)
INSERT into mytable (col1,col2) values (1,2)

First one explicitly sets it to null while the second implicitly sets it to null (if no default value has been specified for the date column).

For updating, you must explicitly set it to NULL.

HTH

Andy
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On