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;
Wednesday, August 15, 2012
HTML mail from SybaseIQ- Sendmail linelength problem (weird ! character)
One of the best ways to send HTML mail from SybaseIQ on IBM AIX is to use sendmail.
Unfortunately sendmail has linelength limit (2040 characters default). After 2040th character sendmail is adding ! and new line characters to text which is ruining HTML.
To fix this problem:
Unfortunately sendmail has linelength limit (2040 characters default). After 2040th character sendmail is adding ! and new line characters to text which is ruining HTML.
To fix this problem:
- Change Linelimit info in Sendmail.cf file. Add L=4096 (or any other suitable value) to corresponding mailer.
- To identify correct mailer check mail log at /var/log/maillog file. Mailer name is mostly Mrelay
- After these steps ! character shall be removed from your mail.
- You may add || CHAR(13) || CHAR(10) after each </tr> statement to add new line in SQL as well.
execute immediate 'exec xp_cmdshell ''(echo "From: myadreess@mail.com."; echo "To: dest1@mail.com,dest2@mail.com"; echo "MIME-Version: 1.0";echo "Content-Type: text/html"; echo "<html><body bgcolor=black><blockquote><font color=green>GREEN</font> <font color=white>WHITE</font> <font color=red>RED</font><font color=blue>Powered by Sybase IQ</font></blockquote></body></html>") | sendmail -t''';
Thursday, June 14, 2012
SYBASE IQ - Split coma seperated values in to rows
To split delimiter separated values in to rows use sa_split_list function
Usage:
Usage:
SELECT * FROM sa_split_list( 'Tee Shirt,Baseball Cap,Visor,Shorts' ); |
line_num | row_value |
---|---|
1 | Tee Shirt |
2 | Baseball Cap |
3 | Visor |
4 | Shorts |
For detailed intormation check Sybase Documentation.
Thursday, June 7, 2012
How to get folder and subfolder size in readable format unix
AIX code is below, for orther unix systems use lower h
du -gH /* | sort -n
du -gH /* | sort -n
Tuesday, June 5, 2012
Sybase IQ - Word Index limitations
"words exceeding the maximum permitted word length not supported" error means you did not defined enough/correct delimiters for WD index.
Maximum word length for WD index is 255 characters. You need to delimit your text with correct delimiters to reduce maximum word length under 255.
For columns, which holds SQL statements, delimited by ' ,;=' clause seems valid.This statement means string will be delimited by any of those characters. '.' character is willingly ommited to be able to find 'owner.tablename' format faster.
You may check Sybase Infocenter for detailed information.
Maximum word length for WD index is 255 characters. You need to delimit your text with correct delimiters to reduce maximum word length under 255.
For columns, which holds SQL statements, delimited by ' ,;=' clause seems valid.This statement means string will be delimited by any of those characters. '.' character is willingly ommited to be able to find 'owner.tablename' format faster.
You may check Sybase Infocenter for detailed information.
Tuesday, May 29, 2012
Sybase IQ equavelent for while break structure
Sybase IQ uses labes to exit loops. Instead
of break you have to use exit label structure.
Sample "while break" code:
.
.
lbl:
WHILE 10 <15 LOOP
SET i = 1;
IF i = 1 THEN
LEAVE lbl;
END IF;
END LOOP lbl
.
.