All Forums Tools
denilsson10 6 posts Joined 04/15
07 Apr 2015
String-genererated SQL-statment into BTEQ

Hi!
I have created a SQL-statement that is in a string.
Ex:
'insert into MetadataTable.TestTable ' !!
'sel ''' !! trim(substr(Col.databasename,1,3)) !! ''' as Environment, ''' !!

trim(T1322.Id) !! ''' as Id, ''' !!

trim(T1324.RId) !! ''' as RId, ''' !!

trim(substr(Col.databasename,4,20)) !! ''' as DatabaseName, ''' !!

trim(Col.tablename) !! ''' as TableName, ''' !!....etc etc.
As it is right now - I´m running it in SQL Assistent but my goal is to run it as a scheaduled batch job in Z/OS.
Can someone help out here - how to
1. Run the "genereate-sql-statment. Which will generate an outfil
2. Make it run the generate sql-statement in a new script/source the the outfile from step 1.
Brgds

Glass 225 posts Joined 04/10
07 Apr 2015

Here's a snippit that should help you out:
 

.run FILE LOGON..

.set width 250
.set errorout stdout
.set quiet ON
.set titledashes OFF

.export FILE sql.txt

SELECT
...
;

.if ERRORCODE <> 0 THEN .quit 4;
.export RESET
.set quiet OFF

.run FILE sql.txt
 
Rglass

denilsson10 6 posts Joined 04/15
08 Apr 2015

Thanx 'Glass' I will try this.
//D

You must sign in to leave a comment.