BTEQ .SET RECORDMODE ON; in Unix creating illegible characters.

Tools
Highlighted

BTEQ .SET RECORDMODE ON; in Unix creating illegible characters.

I am trying to export an SQL query from a table - this is in a standard query format i.e.

INSERT INTO DATABASE_A.TABLE_B

SELECT

COUNT(*)

FROM DATABASE_A.TABLE_A

WHERE TABLE_A.REF_1 = 0;

I then use bteq to export it in to a file so I can execute queries in order. I want to preserve the format of the query (as it can contain comments) however on export - the file is presented with: 

^D▒^D▒INSERT INTO DATABASE_A.TABLE_B

The code I am using to export is:

bteq <<-EOF

.LOGON ${LOGON};

DATABASE DATABASE_A;

.WIDTH 65531

.EXPORT DATA FILE=rw_test_sql.dat

.SET RECORDMODE ON;

.RETLIMIT 2147483407,2048;

        .SET SEPARATOR 0;

        .SET NULL AS '';

.SET SESSION CHARSET 'UTF8';

.set titledashes off;

 

SELECT

REQUEST_TEXT

FROM DATABASE_A.TABLE_A;

 

.IF ERRORCODE <> 0 THEN .QUIT 8

.EXPORT RESET

.QUIT 0

EOF

I am using Solaris 10 on KSH. so my question to you is do you know what the cause of this is and how to resolve it?

.SET RECORDMODE OFF; does solve it however the SQL comes in its unformatted text causing it to fail with comments.


 

Tags (1)
1 REPLY
Enthusiast

Re: BTEQ .SET RECORDMODE ON; in Unix creating illegible characters.

DATA : returns the results of a query to a file for processing by other programs. BTEQ returns data in Record mode and stores it in FastLoad format output file. Use this format to interchange data between BTEQ, FastLoad, and FastExport. MultiLoad also accepts the FastLoad format.

Please use REPORT instead of that then you will not get any control chars.

.EXPORT REPORT FILE