|
View previous topic :: View next topic
|
| Author |
Message |
nartcr
New User
Joined: 06 Jun 2007 Posts: 83 Location: anada
|
|
|
|
I am unloading few columns from my DB2 table, and running through SYNCSORT.
Each column is '|' delimited. The second column, shows following definition in DB2 table - Integer NULLIF (196) = '?'. Whats the best way to convert the column to ZD format, and replace all null fields with spaces. I tried searching the forum with vain, and going through manual. If someone could point me exactly how can I do this would appreciate it.
In DB2 statement, this will be equivalent of CHAR(COALESCE(<fieldname>,' ')) function.
| Code: |
*****************
|2013-11-28| ::è|
4FFFF6FF6FF400054
F2013011028F0234F
----------------
|2013-11-28| õ:|
4FFFF6FF6FF400C14
F2013011028F00FFF
----------------
|2013-12-12| ::,|
4FFFF6FF6FF400164
F2013012012F025BF
----------------
|2013-12-12| :³¾|
4FFFF6FF6FF400FB4
F2013012012F01A9F
----------------
|2013-12-12| ::x|
4FFFF6FF6FF4000A4
F2013012012F0227F |
| Code: |
162:182,10,C'|',
173:192,BI,ZD,LENGTH=9,C'|' |
After going through manual, I tried 173:192,4,C'|' |
|
| Back to top |
|
 |
nartcr
New User
Joined: 06 Jun 2007 Posts: 83 Location: anada
|
|
|
|
I think I didn't put question well, I understand I can do
| Code: |
173:192,4,BI,EDIT=(TTTTTTTTTT),C'|')
|
to convert from BI to ZD format. However, how do we check for a null character in a specific position, do I need to do INREC Parsing or something ? |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| There is no "null character". If a column can be NULL, there will be a separate indicator for each row to tell you whether the value is NULL or not, and you use that. If you have not used that explicitly or implicitly in the preparation of your data, then you need to do that. |
|
| Back to top |
|
 |
nartcr
New User
Joined: 06 Jun 2007 Posts: 83 Location: anada
|
|
|
|
| Bill Woodger wrote: |
| There is no "null character". If a column can be NULL, there will be a separate indicator for each row to tell you whether the value is NULL or not, and you use that. If you have not used that explicitly or implicitly in the preparation of your data, then you need to do that. |
You are right. I havent been able to keep my head straight, and not sure what was i thinking when i wrote the original query..
Say:
EMP_IDNUM SMALLINT - position 1-3
EMP_NUM INTEGER (IF NULL POS(4) = '?') [ records with no emp_num suggests "contractor"/"consultant"] position 4-7
EMP_NAME VARCHAR position 8-50
EMP_AMOUNT DECIMAL(11,2) position 50 onwards
Varchar normally has first 2 bytes of the particular field to indicate the type of data. Ifnull for an integer would have last byte turned on for null character.
If you can let me know, if it would be INREC and PARSE that could achieve this, it would be helpful. |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| Gernerally, if the data is variably-located, you would use PARSE. If in fixed locations, of fixed size, just define the fields (start-positio,lenght - without data-type in a BUILD/OVERLAY/PUSH (generally) and with data-type for an IFTHEN. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|