All Forums Tools
03 Jul 2011
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?


dnoeth 4628 posts Joined 11/04
05 Jul 2011

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.



You must sign in to leave a comment.