How to use EXEC SQL in Bteq ?

Tools & Utilities
Teradata Employee

How to use EXEC SQL in Bteq ?

Hi all.
I have a file with a list of stats i have to collect (id, sentemce, date), and the Id of the stat according to a parameters table.
I need to run the stat and insert a record in a log table with start_time and end_time.
So I tought i could do a Bteq Import reading the file, that way I can insert into the log table with the Id of the stat when the execution starts and update it when it ends. The problem is between these two sentences i have to run the collect stats sentence wich would be in a bteq variable :stat. I tought I could do this with an Exec Sql :stat; but I cant make it work.

So the first question is, is it possible to use exec sql in a bteq import ?
If not, any suggestions?
If yes, can you share an example?

Tks.
Tags (1)
1 REPLY
Junior Contributor

Re: How to use EXEC SQL in Bteq ?

No and yes, yes ;-)

dbc.sysExecSQL is only valid in SPs, so you could create an SP which CALLs dbc.sysExecSQL and then CALL this SP in Bteq.
BUT, this is dangerous, keyword "SQL injection"

Or you do the classical "EXPORT valid SQL statements" and then use this file for an IMPORT.

I wouldn't do neither, this is a task for a procedure. You just call the SP which does all the checking and maintains the log table.

Dieter