Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

updating DB2 date values

Status
Not open for further replies.

rk68

Programmer
Jul 15, 2003
171
IN
I am using JSP script which update/inserts some value into DB2, but getting error while doing the same.
The script is passing some values which uses the same in the update/insert SQL. The date value is initialized as null in a variable & this variable is called in the SQL statement. If the date is null it passes a null value & this gives error.
============
The SQL script using JSP is as follows:
String UpdSql = "update db2admin.T_CUS_NAP set " ;
UpdSql = UpdSql + "(CUS_ORG, CUS_PTNR1_DOB, CUS_PTNR1_SPS_NM, CUS_PTNR1_SPS_DOB) = ('";
UpdSql = UpdSql + Ndname + "','" + Np1_dob + "','" + Np1_spnm + "','" + Np1_spdob +"'";
=================
The variable is cus_ptnr1_dob if contains a date then the SQL works fine but if its a null value then gives error as the SQL passes the null value with quotes ('null') which is not accepted in DB2 for date values.
How do I get this done ?
Please Help.

TIA
Raj



 
Raj,
Are you sure that the field is nullable?

Also, when DB2 executes the statement, the quotes must not be present, so the clause should read:

CUS_PTNR1_DOB = NULL

Hope this helps.

Marc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top