little tips and tricks, which i stumbled upon randomly

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:
  1. Change Linelimit info in Sendmail.cf file. Add L=4096 (or any other suitable value) to corresponding mailer.
  2. To identify correct mailer check mail log at /var/log/maillog file. Mailer name is mostly Mrelay
  3. After these steps ! character shall be removed from your mail.
  4. You may add ||  CHAR(13) || CHAR(10) after each </tr> statement to add new line in SQL as well.
Sample script which sends HTML mail from Sybase IQ is below
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:

SELECT * 
  FROM sa_split_list( 'Tee Shirt,Baseball Cap,Visor,Shorts' );

line_numrow_value
1Tee Shirt
2Baseball Cap
3Visor
4Shorts
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

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.

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
.
.

Wednesday, May 9, 2012

Important tip about great career building

3:51 AM By

"Obsessively specialize. No niche is too small if it's yours."


For sure this is one of the best tips for successful career.
Knowing something about everything can be good in daily life but to climb steps in your career, know everything about something. It doesn't matter if it is small or big topic. nBe expert, get as many certificates as possible (if they exist), share your expertise online and build reputation around it.

Wednesday, April 11, 2012

How to use '\' character in Sybase IQ procedures

When you compile any procedure with '\' in Sybase IQ, your code will be replaced with '\\' to avoid whis
use CHAR(92) instead.

CREATE PROCEDURE MY_TEST
BEGIN
        SELECT LIST(TABLE_NAME, CHAR(92)) FROM SYSTABLES;
END;
/