SET feedback off;
SET echo off;
SET verify off;
SET heading off;
SET trim ON;
SET tab ON;
SET colsep ' ';
SET trimspool ON;
SET term off;
spool bil_user.txt
SELECT
(
cast(cd.id_str AS varchar(20))
|| ' ' || coalesce(cp.id_place, 0)
|| ' ' || coalesce(cp.id_connect, 0)
|| ' ' || coalesce(cd.ip_adr, ' ')
|| ' ' || coalesce(cd.owner, ' ')
|| ' ' || coalesce(cd.login_name, ' ')
|| ' ' || coalesce(cp.address, ' ')
) AS record
FROM
BIL.CONNECT_DETAIL cd
LEFT JOIN BIL.CONNECT_PLACES cp ON (cp.id_place = cd.id_place)
;
spool off;
SET term ON;
exit