View previous topic :: View next topic
|
Author |
Message |
arien
New User
Joined: 02 Nov 2006 Posts: 43 Location: London
|
|
|
|
Hi,
Couple of questions on logic clarification and need help on my approach here:
I need to UNLOAD a table into a comma-delimited text file and while unloading there should be a table join condition in the WHERE clause of the table.
I tried unloading using DSNUPROC, and it unloaded the complete table perfectly into delimited text file, but it comes with it's disadvantage that it cannot work with table joins? Is that correct ?
Next, I am trying with DSNUTILA, but it seems SELECT statement in SYSIN has a character limit of 72 characters? (Correct me if I am wrong here)What if I need to explicitly mention all the columns of a big file...
Also, how can I mention the column delimiter in SELECT sql without explicitly separating the Selected columns . Eg. if A B C are column names, my SQL for pipe-delmited output is something like :
SELECT A,'|',B,'|',C from sample;
Please suggest a solution?
Thanks |
|
Back to top |
|
|
arien
New User
Joined: 02 Nov 2006 Posts: 43 Location: London
|
|
|
|
Does that mean I need to write the parsing logic in a program instead ?? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Suggest you post a few rows from both tables (relevant columns only) and the delimited output you want from the sample data. |
|
Back to top |
|
|
arien
New User
Joined: 02 Nov 2006 Posts: 43 Location: London
|
|
|
|
Thanks D.sch.
Just for example. My sample data has 2 input tables - EMP and SCENARIO
EMP data:
Code: |
EMPNO ScNo Salary Name Update_date
1000 1 9000 Erick Verghese 2008-01-10 01:03:00.123456
2000 2 1000 Leo Fiterstein 2007-01-01 01:03:00.123456
3000 3 10000 Diane Lee 2010-01-01 01:03:00.123456 |
SCENARIO data:
Code: |
ScNo ScName
1 Has 1 child
2 Is Single
3 Has no children |
My SELECT statement should contain all data from SCENARIO table where update_date in EMP table > 2008-01-01.
Hence my SELECT statement will be :
SELECT * from SCENARIO where ScNo IN (SELECT ScNo from EMP where UPDATE_DATE > '2008-01-01-00.00.00.000000')
And I need my output in the following pipe-delimited format(only 2 records from SCENARIO table qualify):
1|Has 1 Child
3|Has no children
Hope this helps. As I see from DSNUPROC examples, this nested SELECT is not possible.. pls advise. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
I have always used APPENDIX1.4.1 Running DSNTIAUL
where I could simply code any sql select.
in your case I would code:
SELECT ScNo
,'|'
, ScName
FROM ...
in the case of ScNo, depending upon the data type, you may need a cast statement.
the nice thing about DSNTIAUL, you can always run the same sql in spufi. |
|
Back to top |
|
|
arien
New User
Joined: 02 Nov 2006 Posts: 43 Location: London
|
|
|
|
Thanks Db..
I could unload the table into a pipe-delimited flat file. But this SELECT statement has introduced spaces in between columns.
Eg: my output became:
1 | Has 1 Child
3 | Has no children
And second problem that I am facing is that the SMALLINT, DECIMAL format fields have become unreadable. any way around this? can I convert the output into ASCII format? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
You want your output to be plain text. The smallint and decimal fields are unreadable because they are still in the internal numeric format.
When you create the plain text delimited file, an ftp of the data to a unix or win-based system will automatically handle the ebcdic->ascii conversion. |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
Code: |
SELECT ScNo
,'|'
, ScName |
The literal '|' is a varchar field you have to cast as a char field! |
|
Back to top |
|
|
arien
New User
Joined: 02 Nov 2006 Posts: 43 Location: London
|
|
|
|
DSNUTIAL solves the issue to an extent. There is another utility that I came to know HPU - High Performance Unload. It runs the program INZUTILB. I'm trying to get my output based on this. I will update the forum. |
|
Back to top |
|
|
|