IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Setting NULLs in the Table.


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
the_gautam

Active User


Joined: 05 Jun 2005
Posts: 165
Location: Bangalore

PostPosted: Tue Apr 01, 2008 10:53 pm
Reply with quote

Can anyone help me for UPDATEing a table by setting a particular field as NULL.

say i have a table MYTABLE in which a nullable column MYCOL1 is there. the data is in the table. now i want to UPDATE the table and place NULL values in the MYCOL1.

using cobol program we may do it by passing -1 to the null-indicators but, what about a QUERY?
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Tue Apr 01, 2008 11:59 pm
Reply with quote

the_gautam wrote:
Can anyone help me for UPDATEing a table by setting a particular field as NULL.

say i have a table MYTABLE in which a nullable column MYCOL1 is there. the data is in the table. now i want to UPDATE the table and place NULL values in the MYCOL1.

using cobol program we may do it by passing -1 to the null-indicators but, what about a QUERY?


update mytable set mycol1 = null;

Of course it may be wise to include a where clause.
Back to top
View user's profile Send private message
byearun

New User


Joined: 25 Jul 2005
Posts: 17

PostPosted: Tue Apr 08, 2008 11:52 pm
Reply with quote

I think it will not work. We tried the same in SPUFI. But it failed with SQLCODE -407
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Tue Apr 08, 2008 11:56 pm
Reply with quote

byearun wrote:
I think it will not work. We tried the same in SPUFI. But it failed with SQLCODE -407


Did you even bother to lookup -407 sqlcode?

You can only set a nullable column to null!
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19243
Location: Inside the Matrix

PostPosted: Tue Apr 08, 2008 11:57 pm
Reply with quote

Hello,

Quote:
But it failed with SQLCODE -407
You would get this any way you tried, i believe. . . The column is not nullable. . .

It is usually a good idea to look up the error code . . .
Back to top
View user's profile Send private message
Gnanas N

Active Member


Joined: 06 Sep 2007
Posts: 792
Location: Chennai, India

PostPosted: Tue Apr 08, 2008 11:59 pm
Reply with quote

Quote:
SQLCODE -407

Here, updating column shouldn't be defiened as NOT NULL...
Back to top
View user's profile Send private message
byearun

New User


Joined: 25 Jul 2005
Posts: 17

PostPosted: Wed Apr 09, 2008 12:11 am
Reply with quote

Yes, I was trying to update the column which is defined as NOT NULL. How this can done thru SPUFI.
Back to top
View user's profile Send private message
byearun

New User


Joined: 25 Jul 2005
Posts: 17

PostPosted: Wed Apr 09, 2008 12:14 am
Reply with quote

To more specific, i want to update a null value in the column which has defined as NOT NULL
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19243
Location: Inside the Matrix

PostPosted: Wed Apr 09, 2008 12:17 am
Reply with quote

Hello,

Quote:
To more specific, i want to update a null value in the column which has defined as NOT NULL
This cannot be done.

Someone went to some length to define the column as not nullable. Why would you believe it was acceptable for you to force the column to null?

It is probably time for you and your peers to talk with your manager and/or the dba(s) and decide which way the definition should be.
Back to top
View user's profile Send private message
View previous topic : : View next topic  
Post new topic   Reply to topic All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts count contained values of several col... DB2 5
No new posts To join 2 tables and to join 3rd tabl... DB2 8
No new posts Setting RC using NULLOFL/NOTMTOFL for... SYNCSORT 6
No new posts Create a specific record/file based o... SYNCSORT 8
No new posts Extract ISPF table column headings CLIST & REXX 2
Search our Forums:


Back to Top