Hi, I am new to teradata SPs n trying to write a loop. Below is the sample code, I want to assign QUERIES to variables SQLTXT1,SQLTXT2,SQLTXT3 ... and run with SYSEXECSQL. so I can run any no. of queries in loop and want to leave loop if SQL_ERR_CODE <> 0 . SET Count=0 SET SQLTXT1='DELETE FROM '||DBNAME||'.TABLE'; SET SQLTXT2='INSERT INTO '||DBNAME||'.TABLE SELECT * FROM '||DBNAME||.TABLE1'' SET SQLTXT3='QUERY.....' .. .. .. L1: LOOP Q1: BEGIN DECLARE EXIT HANDLER FOR SQLEXCEPTION SET COUNT=COUNT+1; SET SQLTXT='SQLTXT:COUNT'; CALL DBC.SYSEXECSQL(:SQLTXT) END Q1; GET DIAGNOSTICS EXCEPTION 1 ERRMSG = MESSAGE_TEXT; IF COUNT=2 OR SQL_ERR_CDE<>0 THEN LEAVE L1; END IF; END LOOP L1; I am not able to assign a query from SQLTXT1,2,3 ... to SQLTXT variable. I am doing like this to capture log for every query I run in SP. Please help me on this. Best Regards, Mahesh
To use RESTORE, leave the original table alone; if you want a backup of the contents, make a new backup table.
If you create a new target table, you must (re)GRANT any the access rights held on the original, and use COPY command instead of RESTORE.