How to process cedilla delimiter in redshift copy,unload commands inside a stored procedure(Copy delimiter single byte character)?

23 views Asked by At

My query is like this:

unload('select * from table') to 's3://path'
credentials '*******'
header
parallel off
delimiter as '\307'

The delimiter is Cedilla Ç. and I have to unload it like this '\307'. When I execute the query directly, it works. But when I tried to execute it from redshift stored procedure, BAD UTF8 hex sequence: C7 27 (error 4) is observed.

create or replace procedure unload_table(in path varchar)
as 
$$
begin
execute
'unload(''select * from table'') to ''||path||''
    credentials '*******'
    header
    parallel off
    delimiter as ''\307'';';
end;
$$ language plpgsql;

I tried calling the procedure using

call unload_table('s3://path')

I had a very long query but I checked each and every issues finally when i replaced the cedilla delimiter '\307' by pipe delimiter '|' , the procedure worked. But, I would need the output file with '\307' delimiter only. Also, I am using redshift copy command, before this query with same delimiter, So I had issues there also. So, unloading in '|' delimiter and changing the delimiter later will not be good option here.

Since, it is a dynamic SQL, '\307' is not supported as a string, and when I try to use Ç, directly in a dynamic SQL, i got the error as COPY delimiter must be a single one-byte character.

Any way that I can support this delimiter from inside a stored procedure in redshift.

0

There are 0 answers