Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Setting NULLs in the Table.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: Setting NULLs in the Table.
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    Post subject: Re: Setting NULLs in the Table.
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    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Tue Apr 08, 2008 11:57 pm    Post subject:
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: 785
Location: Chennai, India

PostPosted: Tue Apr 08, 2008 11:59 pm    Post subject:
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    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Wed Apr 09, 2008 12:17 am    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am
No new posts Regarding COBOL Stored Procedure opti... selvamsrinivasan85 DB2 4 Fri Nov 04, 2016 8:57 pm
No new posts Need Rexx Program to Load in to DB2 T... Hareesh Verma CLIST & REXX 22 Tue Sep 20, 2016 2:59 pm
No new posts Command UNIQUE CONSTRAINT on any tabl... rohanthengal DB2 2 Thu Aug 18, 2016 3:48 pm
No new posts Updating online Db2 table kishpra DB2 3 Fri Aug 12, 2016 2:44 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us