Can a BTEQ script be called from another BTEQ script?

Tools

Can a BTEQ script be called from another BTEQ script?

Can we call a BTEQ script from another BTEQ script? I am working on MS-DOS.

Also I have another question on "activitycount".

Is it possible to get activitycount on any INSERT|UPDATE|DELETE operation on a table? If yes how.
Tags (1)
3 REPLIES
Enthusiast

Re: Can a BTEQ script be called from another BTEQ script?

Q1 ) Yes ,

BTEQ
.LOGON username,password
.RUN FILE=[qualifier]filename <--- this way
INSERT INTO userid.Employee
SELECT * FROM Personnel.Employee;
.LOGOFF

Q2 ) database personnel;
select empno
,hours from charges
where proj_id = ’oe1-0001’
order by empno;
.IF activitycount = 0 then .GOTO SECTIONA
.IF activitycount >= 1 then .GOTO SECTIONB
.label SECTIONA
.REMARK ’Zero Hours on Account’
.label SECTIONB
.REMARK ’Total Hours on Account’
.logoff
.exit

Re: Can a BTEQ script be called from another BTEQ script?

Can you expand on the sample given above?

I am calling one beteq script from another, however control is not returning to the calling script to continue running.

In the example above the INSERT INTO userid.Employee SELECT * FROM Personnel.Employee; will not run.

When the called script ends I get the message *** Warning: EOF on INPUT stream.

One post mentioned that all scripts need to end with an Exit or Quit. This is a pain if the user has to constantly reconnect to the database to continue with the script!!

So the question is. What does the script above end with?   .RUN FILE=[qualifier]filename <--- this way

Thankyou

Junior Supporter

Re: Can a BTEQ script be called from another BTEQ script?

It works (even 'nested' calls), but not in 'interactive mode':

caller.sql:

.logon my_db/user,password
select date caller1;
.run file C:\Process\called.sql
select date caller2;
.quit

called.sql:

select current_timestamp(0) called1;
.run file C:\Process\called2.sql

called2.sql:

select current_timestamp(0) called2;

Then:

C:\Process>bteq < caller.sql

BTEQ 13.10.00.01 Tue Oct 25 11:07:54 2011

+---------+---------+---------+---------+---------+---------+---------+----

.logon my_db/user,

 *** Logon successfully completed.

 *** Teradata Database Release is 12.00.02.46

 *** Teradata Database Version is 12.00.02.46

 *** Transaction Semantics are BTET.

 *** Session Character Set Name is 'ASCII'.

 *** Query completed. One row found. One column returned.

 *** Total elapsed time was 3 seconds.

select date caller1;

 *** Query completed. One row found. One column returned.

 *** Total elapsed time was 1 second.

 caller1

--------

11/10/25

+---------+---------+---------+---------+---------+---------+---------+----

.run file C:\Process\called.sql

+---------+---------+---------+---------+---------+---------+---------+----

select current_timestamp(0) called1;

 *** Query completed. One row found. One column returned.

 *** Total elapsed time was 1 second.

                  called1

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

2011-10-25 11:07:57+00:00

+---------+---------+---------+---------+---------+---------+---------+----

.run file C:\Process\called2.sql

+---------+---------+---------+---------+---------+---------+---------+----

 *** Warning: EOF on INPUT stream.

select current_timestamp(0) called2;

 *** Query completed. One row found. One column returned.

 *** Total elapsed time was 1 second.

                  called2

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

2011-10-25 11:07:57+00:00

+---------+---------+---------+---------+---------+---------+---------+----

select date caller2;

 *** Query completed. One row found. One column returned.

 *** Total elapsed time was 1 second.

 caller2

--------

11/10/25

+---------+---------+---------+---------+---------+---------+---------+----

 *** Warning: EOF on INPUT stream.

.quit

 *** You are now logged off from the DBC.

 *** Exiting BTEQ...

 *** RC (return code) = 0

C:\Process>

HTH.

Cheers.

Carlos.