String-genererated SQL-statment into BTEQ

Tools
Enthusiast

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

Tags (3)
2 REPLIES
Enthusiast

Re: String-genererated SQL-statment into BTEQ

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

Enthusiast

Re: String-genererated SQL-statment into BTEQ

Thanx 'Glass' I will try this.

//D