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 

Output from Batch SQL

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
NASCAR9
Intermediate


Joined: 08 Oct 2004
Posts: 274
Topics: 52
Location: California

PostPosted: Fri Apr 17, 2009 11:50 am    Post subject: Output from Batch SQL Reply with quote

Is it possible to output spaces instead of low values when running SQL in a batch job? We are running DB2 V9 CM

The output below is B.PAT_LNAME and B.PAT_FNAME and looks like this:

Code:

...JAMES.....................................BUDD....
...JAMES.....................................BUDD....
...JAMES.....................................BUDD....
...TERRI.....................................OYE.....


Jcl looks like this:
Code:

//STEP0170 EXEC PGM=IKJEFT01                           
//SYSTSPRT DD  SYSOUT=*,DCB=BLKSIZE=121                 
//SYSPRINT DD  SYSOUT=*                                 
//SYSTSIN  DD  *                                       
 DSN SYSTEM(DB2P)                                       
 RUN  PROGRAM(DSNTIAUL) -                               
      PLAN(DSNTIB81)    -                               
      PARMS('SQL,1,TOLWARN(YES)') -                     
      LIB('DB2P.DSN.RUNLIB.LOAD')                       
//SYSREC00 DD  DSN=TF.MD.GIG.C4600,                     
//             SPACE=(CYL,(3000,2000),RLSE),           
//             DCB=(RECFM=FB,LRECL=1000,BLKSIZE=26000),
//             DISP=(NEW,CATLG,DELETE)                 
//SYSPUNCH DD SYSOUT=*                                 
//SYSIN    DD *                                         
 SELECT SUBSTR(DIGITS(IFNULL(B.PAT_SSN , 0)),2,9)       
       ,SUBSTR(DIGITS(IFNULL(B.PART_SSN, 0)),2,9)       
       ,IFNULL(C.OCC_FROM_DATE, '9999-12-31')           
       ,IFNULL(C.OCC_TO_DATE,   C.OCC_FROM_DATE)       
       ,IFNULL(A.PAT_DOB, '9999-12-31')                 
       ,RTRIM(IFNULL(B.PAT_LNAME, ' '))                 
       ,IFNULL(B.PAT_FNAME, ' ' )                       

_________________
Thanks,
NASCAR9
Back to top
View user's profile Send private message
NASCAR9
Intermediate


Joined: 08 Oct 2004
Posts: 274
Topics: 52
Location: California

PostPosted: Fri Apr 17, 2009 12:24 pm    Post subject: Reply with quote

The above columns are VARCHAR
_________________
Thanks,
NASCAR9
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Fri Apr 17, 2009 12:29 pm    Post subject: Reply with quote

NASCAR9,

Well RTRIM returns a varchar string so you see low values in them, but is your intention to trim the spaces and have the last and first names together?

like
Code:
JAMES BUDD
instead of
Code:
JAMES.....................................BUDD
Back to top
View user's profile Send private message Send e-mail Visit poster's website
NASCAR9
Intermediate


Joined: 08 Oct 2004
Posts: 274
Topics: 52
Location: California

PostPosted: Fri Apr 17, 2009 1:01 pm    Post subject: Reply with quote

kolusu I tried 'RTRIM' as a test and I failed. The output columns are fixed length. The columns are defined as VARCHAR and when I code this :
Code:

IFNULL(B.PAT_FNAME, ' ' )

it still outputs low values. I'm trying to default to spaces x'40' but it's coming out x'00'
Code:

 ----------------------------------------------------
BUDD......................................JAMES......
CECC00000000000000000000000000000000000000DCDCE000000
24440000000000000000000000000000000000000511452000000
 ----------------------------------------------------


Does this help
_________________
Thanks,
NASCAR9
Back to top
View user's profile Send private message
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Fri Apr 17, 2009 1:12 pm    Post subject: Reply with quote

don't know quite how to write the sql, don't have any testing facility, but,

using substr(column,1,locate(column,x'00')) might get it.

you can substitute instr for locate.
_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Fri Apr 17, 2009 1:16 pm    Post subject: Reply with quote

NASCAR9,

You still did not answer my question as to if you need to concatenate last name and first name together. You need CHAR function on the string to have spaces instead of low-values. Anyway you can use one of the following depending on your need

Code:

CHAR(RTRIM(IFNULL(B.PAT_LNAMEV, ' ')) ||
     CHAR(' ')                        ||
     RTRIM(IFNULL(B.PAT_FNAMEV, ' ')))        


will produce
Code:
JAMES BUDD


Code:

 CHAR(IFNULL(B.PAT_LNAMEV, ' '))
,CHAR(IFNULL(B.PAT_FNAMEV, ' '))        

will produce
Code:

JAMES                                     BUDD
Back to top
View user's profile Send private message Send e-mail Visit poster's website
NASCAR9
Intermediate


Joined: 08 Oct 2004
Posts: 274
Topics: 52
Location: California

PostPosted: Fri Apr 17, 2009 1:33 pm    Post subject: Reply with quote

kolusu, I'm sorry I thought I was clear when I said 'Fixed Length' but I can see where it was confusing. The columns are seperate like your second example.
And THANK YOU! You once again had the correct solution! You can see the colunm with the 'CHAR' function and the column without it.

Code:

JAMES                                   ..BUDD.................
DCDCE4444444444444444444444444444444444400CECC00000000000000000
114520000000000000000000000000000000000004244400000000000000000
 --------------------------------------------------------------


_________________
Thanks,
NASCAR9
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database 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