Control characters in output file

Tools & Utilities
Enthusiast

Control characters in output file

I use below script basically bteq and then export to flat file. It gives error as below, but geneartes files with control characters in the beginning. Can someone help please on removing control characters and making below script run.

.BEGIN EXPORT SESSIONS 1;
*** Error: Unrecognized command BEGIN

.END EXPORT;
*** Error: Unrecognized command END

Script
#!/bin/ksh

bteq<<bteqend
.SESSIONS 1;

.logon 132.201.98.80/xxx,xxx123;
DATABASE SDR_ACCESS_VIEWS;

CREATE VOLATILE TABLE MY_SUPV AS
(SELECT DISTINCT
COALESCE(cast(ATTRIB.SBC_USER_ID as varchar(20)),'') as Supv_Attuid,
ATTRIB.SALES_RES_ID as Supv_srid,
COALESCE(cast(ATTRIB.FIRST_NM as varchar(40)),'') as Supv_FirstName,
COALESCE(cast(ATTRIB.MIDDLE_NM as varchar(40)),'') as Supv_MiddleName,
COALESCE(cast(ATTRIB.LAST_NM as varchar(40)),'') as Supv_LastName
FROM
SDR_ACCESS_VIEWS.VCCR0H8S_SALES_RES_ATTR ATTRIB,
SDR_ACCESS_VIEWS.VCCR0H5S_ORG_NODE_SUPVSR SUPV
WHERE
ATTRIB.SALES_RES_ID = SUPV.SALES_RES_ID
AND ATTRIB.EFF_END_DT >= date
AND ATTRIB.DATA_SNAPSHOT_DT = date
AND ATTRIB.ENTITY_DB_STATUS_ON_SNAPSHOT = 'C'
AND SUPV.EFF_END_DT >= date
AND SUPV.DATA_SNAPSHOT_DT = date
AND SUPV.ENTITY_DB_STATUS_ON_SNAPSHOT = 'C')
WITH DATA
UNIQUE PRIMARY INDEX (Supv_srid)
ON COMMIT PRESERVE ROWS
;

.BEGIN EXPORT SESSIONS 1;

.EXPORT DATA FILE = hierarchy.txt;

SELECT
COALESCE(cast(trim(S1) as varchar(20)),'') || COALESCE(cast(S2 as varchar(20)),'')||
COALESCE(cast(S3 as varchar(40)),'') || COALESCE(cast( S4 as varchar(20)),'')||
COALESCE(cast(S5 as varchar(40)),'')
from MY_SUPV ;

.EXPORT DATA FILE = my.dat;

bteqend
1 REPLY
Enthusiast

Re: Control characters in output file

try this ...

.export file = mydata;

SELECT .....

.export reset;