bteq runfile quit problem

Tools & Utilities
Enthusiast

bteq runfile quit problem

Hi,
I have this bteq, omitted the logon and sql info at the start,
and the RUN_FILE does have some statements that will cause failures:

a)
.export reset
.run file=${RUN_FILE}
.if errorlevel <>0 then .quit 3
.quit 0
EOF1
RC=$?

On running, it returns
+---------+---------+---------+---------+---------+---------+---------+----
*** Warning: EOF on INPUT stream.
+---------+---------+---------+---------+---------+---------+---------+----

.if errorlevel <>0 then .quit 3
.quit 3
*** You are now logged off from the DBC.
*** Exiting BTEQ...
*** RC (return code) = 3

The warning message came because the RUN_FILE didn't end with '.QUIT' or .'EXIT' statement.
So i modified the code as below:

b)
select '.QUIT' (title '');
.export reset

.run file=${RUN_FILE}
.if errorlevel <>0 then .quit 3
.quit 0
EOF1
RC=$?

On running, i get:
.QUIT
*** You are now logged off from the DBC.
*** Exiting BTEQ...
*** RC (return code) = 8

I don't get the warning EOF message anymore, but i don't understand why did the bteq return code change to '8'

c) If you add .QUIT or .EXIT at the end of the run_file, is it only meant to say that no more instructions in the run_file,
or does it cause bteq to quit the session entirely?
Or does Bteq continue with next set of instructions after the .run file command.

Thanks,
-srinivas yelamanchili

4 REPLIES
Teradata Employee

Re: bteq runfile quit problem

ERRORLEVEL is the "severity" assigned to the Teradata Database ERRORCODE returned for the most recent SQL request. A "client-side" BTEQ warning or error doesn't change the ERRORLEVEL, though it may set a nonzero "BTEQ return code". By default, the final "return code" passed back to the OS will be the maximum of the BTEQ return codes and ERRORLEVEL severities encountered.

As far as part C of your question, .QUIT or .EXIT logs off and exits BTEQ entirely.
Enthusiast

Re: bteq runfile quit problem

Thanks Fred.
How can i avoid the 'Warning: EOF on INPUT stream.' message without terminating the bteq?
Is there a way to tell that this is the end of the runfile but not the end of the bteq?

-srinivas
Teradata Employee

Re: bteq runfile quit problem

If BTEQ switches back from the .RUN file to the primary input, you will get the "warning" message. There is no way to avoid that.

But note that the warning does NOT change ERRORLEVEL value, nor does it even set a nonzero "BTEQ return code". So why is displaying the message text a problem?
Fan

Re: bteq runfile quit problem

Hi,

 I need a help with the .RUN command. I have the below file

d:/scripts/File_Name.txt

content of the file :

select count(*) from table_name1 where account_num= '$acc_np_param';

select count(*) from table_name2 where account_num= '$acc_np_param';

select count(*) from table_name3 where account_num= '$acc_np_param';

-------------------------------------------------------------------------------------------------------

Below is the content of my script.

.EXPORT DATA FILE=d:/scripts/count.bteq

.SET RECORDMODE OFF;

.RUN FILE= d:/scripts/File_Name.txt;

.EXPORT RESET

The above command is not working in my script. I need to pass parameter for "acc_np_param" with the .RUN command. Can anyone please help me in this? how to pass a parameter to the .RUN command?

Thanks in advance.