Bteq - How can I write stuff to my output file besides what is returned from the DB?

Tools & Utilities
Junior Supporter

Bteq - How can I write stuff to my output file besides what is returned from the DB?

I am trying to create a Bteq job that writes the SQL results to an output file with a seperator between each set of results.

I need help with making the seperator in the output file. Is it something like "print" or "echo"?

I am not seeing who to do it based on the info in here:

https://developer.teradata.com/sites/all/files/documentation/linked_docs/2414020A_BTEQ-Reference-13....

Desired output example:

2012-01-17 13:07:09.800000+00:00

_________

2012-01-17 13:07:10.320000+00:00

Here is my Bteq code:

.logon IP_ADDRESS/DB_USER,PASS_WORD;

.export data file=/Output_File.out

SELECT current_timestamp;

echo '_________';

.print '_________';

print '_________';


SELECT current_timestamp;

.LOGOFF

.QUIT

Tags (4)
5 REPLIES
Teradata Employee

Re: Bteq - How can I write stuff to my output file besides what is returned from the DB?

Are you really wanting to use DATA format ( rather than REPORT format ) for the selected time stamps ?

Junior Contributor

Re: Bteq - How can I write stuff to my output file besides what is returned from the DB?

ECHO is only allowed in macros, you need

select '_________' (title '');

Dieter

Junior Supporter

Re: Bteq - How can I write stuff to my output file besides what is returned from the DB?

Thanks!

Teradata Employee

Re: Bteq - How can I write stuff to my output file besides what is returned from the DB?

Note that you will only get title values in field mode ( aka Report Mode ).

Teradata Employee

Re: Bteq - How can I write stuff to my output file besides what is returned from the DB?

Also, just a point of clarification... The Teradata SQL statement "ECHO" can be used outside of a macro but can only echo BTEQ commands. To do what you were intending, you could employ the shell command "echo" via BTEQ's .OS command. However, only row data being returned from the database can be exported. So if you were to use a shell command you would need to redirect the OS output to append to the export file. To be able to do that, you have to issue an EXPORT RESET first. You might also have to consider newlines.