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 Export flat file data into excel sheet murali.andaluri DFSORT/ICETOOL 2 Mon Mar 20, 2017 5:39 pm
No new posts Append data from two files into a sin... Praveen04 DFSORT/ICETOOL 5 Thu Mar 16, 2017 7:29 pm
No new posts SPUFI -- Joining 3 tables – data in... Sysaron DB2 2 Wed Mar 08, 2017 4:18 am
No new posts Overriding PS data in rexx Shaheen Shaik CLIST & REXX 8 Fri Mar 03, 2017 5:08 pm
No new posts JCL to get submitted once dataset has... vinu78 JCL & VSAM 17 Thu Feb 16, 2017 7:32 am


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