Quantcast
Channel: Teradata Forums - Database
Viewing all articles
Browse latest Browse all 14773

Create back up tables using cursor - forum topic by mmanijay

$
0
0

Hi All,
Im trying to automate the partitioning range for all tables in teradata.
Is there any query for doing this.
I need to take back up for all tables chnaging the table name '_bkp' added at the end.
I have tried the following stored proc.It is executing but when I call the proc it is throwing an error
CALL Failed 3707:SIMPLEPOC:Syntax error,expected something like an As keyword or '('between the word 'PA__BRANCH_HIER_SNAP' and the word '_bkp').
Im using the below SP:
replace PROCEDURE C4D3CGETLW.SimplePOC()
 
BEGIN
DECLARE vTABLE_DB_NAME VARCHAR(100);
Declare vquery varchar(500);
DECLARE vTABLENAME VARCHAR(800);
Declare name varchar(150);
Declare bname varchar (50);
Declare C_TABLE_VALUES CURSOR FOR
select distinct DATABASENAME||'.'||TABLENAME
FROM DBC.COLUMNS
WHERE DATABASENAME LIKE '%C4D3TARP%'
AND (COLUMNNAME LIKE '%KEY%' OR COLUMNNAME LIKE '%WID%' OR COLUMNNAME LIKE '%ID%'
OR COLUMNNAME LIKE '%CODE%' OR COLUMNNAME LIKE '%DESC%')
AND COLUMNNAME NOT LIKE '%ROW_WID%'
AND TABLENAME like 'PA_BRANCH_HIER_SNAP%' ;
open C_TABLE_VALUES;
fetch C_TABLE_VALUES into vTABLENAME;
set bname = '_bkp';
set name = vTABLENAME||bname;
set vquery = 'create table '||vTABLENAME||'_bkp as (sel * from '||vTABLENAME||' ) with data';
prepare smt from vquery;
execute smt;
close C_TABLE_VALUES;
END ;
Calling the SP using below:
call C4D3CGETLW.SimplePOC( )

Forums: 

Viewing all articles
Browse latest Browse all 14773

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>