MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Unloading table columns properly

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
newcobol
Beginner


Joined: 20 Apr 2006
Posts: 88
Topics: 22

PostPosted: Mon Aug 04, 2014 2:41 pm    Post subject: Unloading table columns properly Reply with quote

table definition, has no nulls
Code:

,DBNA_LOC_NO                    ,INTEGER  ,      4
,DBNA_CTRY_CD                   ,CHAR     ,      3
,DBNA_AIG_CTRY_CD               ,CHAR     ,      3
,DBNA_STATE_ABBR                ,CHAR     ,     10
,DBNA_NATID                     ,CHAR     ,     20
,DBNA_NATID_TYPE                ,CHAR     ,      4


sql:
Code:

SELECT DIGITS(DBNA_LOC_NO)
   ,DBNA_CTRY_CD
   ,DBNA_AIG_CTRY_CD
   ,DBNA_STATE_ABBR
   ,DBNA_NATID
   ,DBNA_NATID_TYPE
FROM CACRADB.TDNB_NAT_ID
FETCH FIRST 10 ROWS ONLY
WITH UR;


data:
Code:

0370036178429429           B151069            0010


why is it puttting a 0 in front of my row
also the syspunch says 10 instead of 9.

when i tried 'char' in front of the integer field,
it wrote out this
370036178 429429  B151069  0010

it put 2 spaces after the first field, and syspunch says 11 instead of 9.

does anyone know why?
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Mon Aug 04, 2014 3:59 pm    Post subject: Re: unloading table columns properly Reply with quote

newcobol wrote:

why is it puttting a 0 in front of my row
also the syspunch says 10 instead of 9.


newcobol,

You have been on these helpboards for quite some time. By now you should be able to debug the errors looking up the manuals. Please spend some time looking into the manuals. If you looked at the DIGITS function in the SQL Reference manual you would have found this

DB2 SQL Reference wrote:

The result of the function is a fixed-length character string representing the absolute value of the argument without regard to its scale. The result does not include a sign or a decimal point. Instead, it consists exclusively of digits, including, if necessary, leading zeros to fill out the string. The length of the string is:

5 if the argument is a small integer
10 if the argument is a large integer
p if the argument is a decimal number with a precision of p


newcobol wrote:

when i tried 'char' in front of the integer field,
it wrote out this
370036178 429429 B151069 0010

it put 2 spaces after the first field, and syspunch says 11 instead of 9.

does anyone know why?


1. Click on the "Quick Manuals" link at the top of this page
2. Scroll down to DB2 section
3. Click on "DB2 V8 SQL Reference" manual
4. Click on the and type in CHAR and click Search
5. Read upon the first entry and see where it discuss about the length of the OUTPUT field.

After you are done reading upon the CHAR function, then insert a Negative value into DBNA_LOC_NO and then use the CHAR function and see what you find in the first byte. That will answer your question as to why you have a space in the first byte for positive numbers.

Please spend time analyzing your problem and refer the manual and if you are stuck, then post the question. You can't expect others to do your work all the time.
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group