Dynamic Bteq script - dbname as parameter

Database

Dynamic Bteq script - dbname as parameter

I have a bteq script which creates procedures inside a database. The dbname say DB1 i will be specified in the bteq command.

The new change we have got now is that the statements inside the procedures would access tables of another DB say DB2.

Can we have a dynamic bteq script where we can specify DB2 too as a parameter??

Or any other solution for this??

Eg: CREATE PROCEDURE DB1.test()

Dynamic result sets 1

BEGIN

DECLARE CUR_LEVEL_LST CURSOR WITH RETURN ONLY FOR

SELECT *   FROM DB2.tablename;

OPEN CUR_LEVEL_LST;

END;

bteq command:DB_SCRIPT.bat DB1 > Log.txt

Inside the bteq script, i execute the procedures with the below command

echo .run file='D:\Procedures\test.DDL'>> script.txt

how can i change the DML statements inside procedure with a dynamic parameter for dbname (DB2) through bteq??

Please advice on the scenario...

Tags (2)