Tags: coding, database, date, db2, field, following, inserting, leaving, mysql, null, null2, nullable, oracle, setting, sql, value

inserting null value to date field

On Database » DB2

1,358 words with 2 Comments; publish: Tue, 04 Dec 2007 23:10:00 GMT; (25078.13, « »)

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???????/

All Comments

Leave a comment...

  • 2 Comments
    • 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

      #1; Tue, 11 Dec 2007 17:51:00 GMT
    • 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

      === Original Words ===

      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

      #2; Tue, 11 Dec 2007 17:52:00 GMT