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
 

 

Unloading data along with coalesce function

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

New User


Joined: 01 Oct 2009
Posts: 3
Location: Hyderabad

PostPosted: Thu Oct 01, 2009 2:52 pm    Post subject: Unloading data along with coalesce function
Reply with quote

Hi,

My requirement is to unload selected data from DB2 table .When it is Null I want default value of '-1' to be assigned to it. For this I use Coalesce Function.Whenever I use this I am getting default values assigned but additional 2 blank bytes are added to the unload data.Please confirm whether by default it will be padded or I am going wrong somewhere.
Back to top
View user's profile Send private message

Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Thu Oct 01, 2009 3:24 pm    Post subject:
Reply with quote

Hi,

It would be nice if you show us the query you've used and the results you get. Please use BBcode tags when you post them, that would make them readable.

Quote:
Whenever I use this I am getting default values assigned but additional 2 blank bytes are added to the unload data.
I'm ot sure what should I conculde from this. COALESCE returns the first argument that is not null.

The arguments are evaluated in the order in which they are specified, and the result of the function is the first argument that is not null. The result can be null only if all the arguments can be null, and the result is null only if all the arguments are null. The selected argument is converted, if necessary, to the attributes of the result. For example, this query
Code:
   SELECT A, COALESCE(B, 0)
     FROM table
will return a value of zero for column B if there is some value for which it is missing in some row (that is, null).
Back to top
View user's profile Send private message
gansin

New User


Joined: 01 Oct 2009
Posts: 3
Location: Hyderabad

PostPosted: Thu Oct 01, 2009 4:33 pm    Post subject:
Reply with quote

Thanks for your reply. Due to some reasons I will not be able to post the code directly.

I am using it in below way

Select COALESCE(A , '-1' )
COALESCE(B, '-1' )
C

Where A is of type x(9),B x(9), C x(3)

My result is 123456789_ _ 12345678_ _ ABC
( last 2 denotes the blank field which I am getting between those 2 fields)

When field A has value it is displaying the value and when it is null it is displaying '-1'. Same case for B.
Back to top
View user's profile Send private message
gansin

New User


Joined: 01 Oct 2009
Posts: 3
Location: Hyderabad

PostPosted: Thu Oct 01, 2009 5:08 pm    Post subject:
Reply with quote

Instead of the above method , do we have any other way to assign the default value to the null field during unload itself ( For unload I am using DSNTIAUL). I am doing selected unload form more than 4 tables joined together.
Back to top
View user's profile Send private message
Bharath Bhat

Active User


Joined: 20 Mar 2008
Posts: 283
Location: chennai

PostPosted: Wed Oct 07, 2009 11:11 am    Post subject:
Reply with quote

I think you are getting null indicators. Coalesce gives you a nullable column.
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 Storing huge volume of data, compare ... Pradeep K M All Other Mainframe Topics 3 Mon Jan 16, 2017 5:08 pm
No new posts how to recover an uncataloged VSAM da... archanamuthukrishnan All Other Mainframe Topics 3 Wed Jan 11, 2017 6:18 pm
No new posts HALDB data refresh/copy from producti... vineetanand2007 IMS DB/DC 1 Mon Jan 02, 2017 11:16 am
No new posts JES2 JEC: Use UNIX Pipes to Pass Data... Virendra Shambharkar JCL & VSAM 21 Tue Dec 20, 2016 6:55 pm
No new posts Is the 'prompt' data for the DSLIST p... Willy Jensen TSO/ISPF 2 Tue Dec 06, 2016 4:38 am


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