little tips and tricks, which i stumbled upon randomly

Tuesday, November 13, 2012

Sybase IQ variable/parametric unload filename

To assign variable in set temporary option temp_extract_name1 use code below:
 

begin
    declare file_name varchar(100);
    declare option1 varchar(100);
   
    set file_name = '/myfolder/myfilename';
    set option1 = 'set temporary option temp_extract_name1=''' + file_name + ''';';
    execute immediate option1;
 
    set temporary option date_format = 'dd.mm.yyyy';
    set temporary option Temp_Extract_Null_As_Empty = 'ON';
    set temporary option Temp_Extract_Quotes = 'OFF';
    set temporary option Temp_Extract_Column_Delimiter = ',';
    select * from my_table;
    set temporary option Temp_Extract_Name1 = '';
end;

0 comments:

Post a Comment