Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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 Copy 4 byte of data from the last rec... arunsoods DFSORT/ICETOOL 9 Fri Oct 06, 2017 12:15 pm
No new posts opening a dataset after reading it fr... arunsoods DFSORT/ICETOOL 5 Wed Oct 04, 2017 3:54 pm
This topic is locked: you cannot edit posts or make replies. PS file data should be passed as symb... d_sarlie JCL & VSAM 15 Tue Oct 03, 2017 5:18 am
No new posts File Aid tool to compare numeric data balaji81_k Compuware & Other Tools 2 Tue Sep 26, 2017 3:35 am
No new posts Question related to Data dictionary f... rexx77 SYNCSORT 3 Thu Aug 31, 2017 7:23 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us