DECLARE vVar1 INTEGER;
SET vVar1= 'VARIABLE'||PRODUCT_NAME
INSERT INTO LOG_Table||PRODUCT_NAME
/*CALLING THE PROCEDURE*/
Here in the above procedure i am trying to pass PRODUCT NAME Dynamically in the call statement so as to insert into the LOG_TABLE based on the value. On doing this i get a syntax error. Operation 1 as shown above doesnt throw error however Operation 2 throws a syntax error as below. Please help me.
Missing/Invalid SQL statement'E(3707):Syntax error, expected something like a 'SELECT' keyword or a 'NONTEMPORAL' keyword or 'AS' keyword between the word 'LOG_TABLE' and '"||"'.'.
You need to use dynamic sql.
Something like this:
Thanks for the reply. But when i am able to append the dynamic value without DBC.SYSEXECSQL in Operation 1 as above why is it not possible to achieve the same in Operation 2. Does Teradata have some limitation?
Yes it is a limitation. You can't do that with an inline sql statement. There are some different ways to handle dynamic sql. Do you have the stored procedures and embedded SQL manual?
You can download it below. Go to www.info.teradata.com and search if you have particular version of Teradata that you would like to find the related manual for.