All Forums Tools
AnK_Q 2 posts Joined 01/09
18 Jan 2009
How to get return code after BTEQ excuted SQL in VBScript

Hi, I want to write a .vbs to let BTEQ excut SQL files. But I don't know how to get return code after BTEQ excuted SQL. Anyone can help me?Here is the sample code.'Run BTEQSet WshShell = CreateObject("WScript.Shell") WshShell.run("bteq")Wscript.sleep 3000'LogonWshShell.SendKeys ".Logon testUser{ENTER}" Wscript.sleep 1000WshShell.SendKeys "testUser{ENTER}"'Excute SQLWscript.sleep 1000WshShell.SendKeys ".run file=""C:\test.sql""{ENTER}"'Get return code'???Regards

Fred 1096 posts Joined 08/04
18 Jan 2009

You may want to ask this question in a Microsoft (WSH) forum; it really has nothing to do with Teradata or BTEQ. I suspect you will need to use Exec method rather than Run.

AnK_Q 2 posts Joined 01/09
18 Jan 2009

Hi Fred ,Thank you for your advise. It seems Run can excute BTEQ but cannot get any return while exec can get stdout, but it can not excute BTEQ....Does anyone know how to excute BTEQ use exec function?

joedsilva 505 posts Joined 07/05
19 Jan 2009

I am not a VB guy, but I suspect that you would also want to add a quit statement at the end of all this.WshShell.SendKeys ".quit {ENTER}"bteq won't terminate in interactive mode without something like that.... and unless any program terminates, you ain't getting any return code.

Petr Horcicka 29 posts Joined 12/08
19 Jan 2009

Hi, Think, that exec should work, see: http://www.microsoft.com/technet/scriptcenter/guide/sas_wsh_pkoy.mspx?mfr=trueYou can also use bteq in batch mode and redirect stdout to file for further processing: "bteq bteq_out.txt"where bteq_wrap.txt contains just a wrapper to open and close bteq session and calls your script saved in "fresh_file.sql":.SET ERROROUT STDOUT.LOGON tdpid/userid, password.RUN FILE="fresh_file.sql".LOGOFF.EXITIt could be easier for debugging, but may it is not so useful in your case :/Petr

Petr Horcicka 29 posts Joined 12/08
20 Jan 2009

uff, it's difficult to upload <, pls. replace LT resp. GT by corresponding symbols for "Less Then" and "Great Then" There should be in the quotation marks 'bteq "LT"bteq_wrap.txt "GT"bteq_out.txt'

You must sign in to leave a comment.