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
 

 

Reg INSERT and UPDATE in DB2

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
srini_igsi
Currently Banned

New User


Joined: 09 Dec 2005
Posts: 30
Location: Pune

PostPosted: Sun Mar 19, 2006 2:43 pm    Post subject: Reg INSERT and UPDATE in DB2
Reply with quote

Hi,

We are facing the following problem after UPDATE a column in DB2.

By default some column's of the table always contain data.
First the program issues a SELECT in the pgm, after this we have a Null Indicator check for the column's we select, if nulls are present, we will INSERT a row into the table. Here my doubt is, after the first SELECT all the Null Indicator varibles will be set to '-1' as applicable, so after moving the data into all the Host Variables and before INSERT, should we also set the Indicator Variables to '0' to avoid inserting the nulls(i think, yes because for the first SELECT all the applicable Indicator variables are set to '-1'). After this again the program issues an UPDATE, but the column's(two) are not getting updated.
As these columns are declared as VARCHAR, we are getting the length of zero for these columns.
So what cud be the reason..??

tx in advance
Back to top
View user's profile Send private message

KS

New User


Joined: 28 Feb 2006
Posts: 91
Location: Chennai

PostPosted: Mon Mar 20, 2006 4:54 pm    Post subject:
Reply with quote

You need not set the null indicator values to 0 explicitly. Once you populate the values it shouldn't be null anymore. While not updating, is it giving an error or warning?? can I get the exact error message and syntax?? When columns are null, u only have to update I guess.

Thanks,
KS
Back to top
View user's profile Send private message
martin9

Active User


Joined: 01 Mar 2006
Posts: 288
Location: Basel, Switzerland

PostPosted: Mon Mar 20, 2006 5:03 pm    Post subject:
Reply with quote

hy srini_igsi,

note: your need indicator variables for NULL-able fields
and for VARCHAR fields, which are never NULL.
VARCHAR with a length of ZERO are like NULL implicitly,
but in DB2 terms there is a difference.
therefore for NULL-able fields you get -1 for NULL in the field
and 0 for not NULL in the field.
for VARCHAR you get always the existing length as a value,
if it is 0 then means the length is 0, what has for you in the
program the same effect (empty). but the indicator value is treated
different...

martin9
Back to top
View user's profile Send private message
srini_igsi
Currently Banned

New User


Joined: 09 Dec 2005
Posts: 30
Location: Pune

PostPosted: Tue Mar 21, 2006 10:12 pm    Post subject: Re: Reg INSERT and UPDATE in DB2
Reply with quote

Thx Martin

Do i need to reset all the Null Indicator Variables (Not VARCHAR) to zero before the pgm issues the INSERT or UPDATE after the first SELECT..?? This is because at the time of first SELECT all the applicable Null Indicator Variables set to '-1'.
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1187
Location: Bangalore,India

PostPosted: Wed Mar 22, 2006 10:17 am    Post subject:
Reply with quote

No You need not to be reset Null Indicator Variables (Not VARCHAR) to zero before the pgm issues the INSERT or UPDATE
It will be set auto matically once u insert some value to the variable

Hope it helps
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 Fileaid Update Replace with null string descann Compuware & Other Tools 4 Mon May 15, 2017 3:00 pm
This topic is locked: you cannot edit posts or make replies. Merge two files and update Trailer re... Yashashri JCL & VSAM 1 Thu May 04, 2017 12:54 pm
No new posts IMS DB-How to update a record (a sing... Nic Clouston IMS DB/DC 9 Thu Mar 09, 2017 4:38 pm
No new posts -913/-911 Deadlock during UPDATE stat... NoSleep319 DB2 5 Fri Nov 18, 2016 12:37 am
No new posts How to update a portion of text in a ... Bill Woodger DFSORT/ICETOOL 25 Wed Nov 09, 2016 9:41 pm


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