little tips and tricks, which i stumbled upon randomly

Monday, December 3, 2012

How to debug in Sybase IQ

5:47 AM By


Sybase IQ- Debugging

1.1            Defining connection for Sybase Central and connectng to database

Open Sybase Central for Java edition
 
"Choose Connection Profiles"
 
Choose "New" to define name & description
Click OK to choose or define ODBC connection
Important: To choose previously defined ODBC connections use
Browse..àShow all data sources .
 
Double click or choose connect:
 

1.2           Choosing code to debug and search criteria management

Choose Procedures & Functions
Define filter in SQL like format
You may use settings buton to filter on users
Important: You have to use submit buton to apply search criteria
 

1.3            Debug mode

Double click on code to open in editor.
Choose dubug button to switch debug mode

 Important: Choose only debug DB user to prevent affecting other users
 

1.4            Break point tanımlanması ve kodun debug modda çalıştırılması

Click on the left side to define break point

Call procedure using a querry tool


 
 
 

 




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;

Readable folder size command in IBM AIX

to get folder size in readable format use
du -gs *| sort -n

click for SUN Solaris command

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;
/

Oracle style LTRIM / RTRIM for SYBASE IQ

Oracle's LTRIM/RTRIM supports second parameter to remove other characters than blank.
For example
select LTRIM('My Textaaaa', 'a') from dual; will return 'My Text'.
Same behavior can be simulated with Sybase IQ as well

LTRIM:
substr(<STRING>, length(<STRING>)-length(ltrim(replace( <STRING> ,<CHARACTERS TO REMOVE>,' ')))+1)

RTRIM:
substr( <STRING> ,1,length(rtrim(replace( <STRING> , <CHARACTERS TO REMOVE> ,' '))))

Tuesday, April 10, 2012

Sybase IQ equavalent for Oracle wm_concat and SQL group_concat

Sybase IQ equavalent for Oracle wm_concat and SQL group_concat is LIST() function.

This function takes 2 parameters column_name (mandotory) and separator (optional default ",").

Sample query:
select list(table_name) from systable

Click for related Sybase Central entry

Tuesday, April 3, 2012

Oracle Translate function equivalent for Sybase IQ

Oracle translate function has many great usages like Eliminating Double Quotes, Encryption/Decryption etc.

I just wrote SybaseIQ version of it. Code can easly be improved but version 1.0 is not a bad place to start.
Source code is below please feel free to use and comment.


CREATE FUNCTION TRANSLATE (
-- -------------------------------------------------------------------------------------
-- Designer    : Ongun Demirler
-- Author    : Ongun Demirler  
-- Description  :    Sybase IQ replacement for Oracle Translate function
--                    Overrides
--
-- Ammedments   :
--    When        Who                    What
--    ===========    ========            =========================================
--    03.04.2012    Ongun DEMIRLER        Initial design and implementation
--
--    Parameters:
--                P_STR: original string
--                P_SRC: source characters
--                P_DEST: destination characters
--  
-- -------------------------------------------------------------------------------------
    P_STR VARCHAR(4000),
    P_SRC VARCHAR(4000),
    P_DEST VARCHAR(4000) )
RETURNS VARCHAR(4000)
BEGIN
 
    DECLARE a_ret_str varchar(4000); --Return string
    DECLARE a_pointer integer; --Character pointer
    DECLARE a_src_length integer; --Length of source string
 
    set a_src_length = LENGTH(P_SRC);
    --No characters to translate from, source or to
    IF LENGTH(P_STR) = 0 OR a_src_length = 0 OR LENGTH(P_DEST) = 0 THEN RETURN ('') END IF;
 
    --Create replace statement for each character in p_src
    SET a_pointer = 1;
    SET a_ret_str = P_STR;
 
    --Replace each character from src with corresponding character from dest
    WHILE (a_pointer <= a_src_length) LOOP
        SET a_ret_str = replace(a_ret_str, SUBSTR(P_SRC, a_pointer, 1) , SUBSTR(P_DEST, a_pointer, 1));
        SET a_pointer = a_pointer + 1;
    END LOOP;
 
    RETURN (a_ret_str);
END


Friday, March 23, 2012

Goldan Gate - GGS ERROR 160 Bad column index

Unfortunately error  message is not explaining much here.
[Date Time] GGS ERROR       160  Bad column index ([Column Count]) specified for table [Owner].[Table Name], max columns = [Column Count].

But reason and solution is simple, new column(s) are added to source table. Check your table definitions and synchronize table structure.

Wednesday, March 21, 2012

iPhone Facebook wifi bağlantı problemi

Özellikle Airties modem kullanıcılarını etkileyen bu sorun aslında modeminizle ilgili.
DNS ayarlarınızı değiştirerek kendi arama motorlarını kullanamızı sağlamaya çalışan garantibul.com, aramamotoru.com (lüften bu siteleri ziyaret etmeyin.) gibi siteler modem şifrenizin olmamasından yada ön tanımlı şifre olmasından faydalanarak modem ayarlarınızı değiştirmiş durumdalar.
Sorunu çözmek için modeminizin fişi çekin. Modemi birkaç saniye sonra tekrar açabilirsiniz.

Modemi açtıktan sonra erişim şifresini değiştirmeniz sorunun tekrarlanmasını önleyecektir.


iPhone Facebook connection problem over wifi

This bug mainly affects Airties users. There is new trojan which changes DNS setting on your modem to use their search engines. (garantibul.com, aramamotoru.com are famous ones in Turkey. Please do not visit these web pages.). To be able to fix this issure just power off your modem. After few seconds you can restart it.
Do not forget to set new password for your modem.

Tuesday, March 20, 2012

AQT (Advanced Query Tool) non unicode character problem

To be able to correctly display and query non unicode languages such as (Turkish) you should
deselect "Enable Unicode features", "For Oracle, Use UNISTR for Unicode strings" and "For Sybase, use TO_UNICAR for Unicode strings". SQL one too if you need it.

Settings are under "Options > General > Unicode Options"



iTunes video add problem - even they are in correct format

Summary: You have to install quicktime to be able to add videos to iTunes.

Although I fully installed and dig trough all settings the in iTunes I wasn't able to add videos to the library even they are in correct format. After spending long time on iternets. It turned out I just have to install quicktime too.

Although quick time is not that good to watch videos here is the link:
http://www.apple.com/quicktime/download/

Something crutial about everything

8:29 AM By

I will just try to share tips &Tricks, how to's which are critical and hard to find on iternets