Reputation: 61
I need to pass output of query to my Datastage Job, which will process it further. Problem is that I used type conversion and calculation in my SQL query, and DataStage needs to know the exact datatype of the input columns.
Simpler way is to guess the column type, for Ex: CAST it to INT But sometimes its INT64 and then I have to change it, so I'm looking for something reliable which will save me time.
More like Metadata of Resultset.
Upvotes: 1
Views: 3214
Reputation: 19005
This depends on how you execute your query.
In the DB2 command line processor you can use the command DESCRIBE SELECT <the rest of your query>
to print the list of result set columns along with their data types.
In a batch script you can parse the output of DESCRIBE
.
In a CLI or embedded SQL application you can use the corresponding DESCRIBE OUTPUT
statement to retrieve the result set metadata into the SQLDA structure.
This assumes DB2 for LUW, but the DESCRIBE
statement is supported by DB2 for z/OS and IBM i (AS/400) as well.
Upvotes: 2