Sunday, April 17, 2011

Checking SQL statement Status in Powerbuilder

Assume that your SQL in Powerbuilder script as below :-

//DECLARE sqlca is your transaction...
transaction SQLCA

SELECT * FROM MYTABLE A WHERE A.MYCOL = '01234' using SQLCA;

if SQLCA.sqlcode = 100 then
    messagabox('Error', 'Record Not Found',StopSign!)
    return
end if

/*
SQLCA.sqlcode = 100 //result not found
SQLCA.sqlcode = 0 //result found or SQL return no error
SQLCA.sqlcode = -1 //returns error in SELECT or INSERT or UPDATE
*/

Thursday, April 7, 2011

First Character of Word UpperCase in SQL

SELECT INITCAP(A.NAME) FROM BIODATA A;

//data example : HARIMADA SABALKUNAN
//SQL output example : Harimada Sabalkunan

Getting Column Data Length with SQL in Oracle

SELECT * FROM RESULTS A
WHERE LENGTH(A.MATRIXNO) = 8;


//Above SQL will select data from table RESULTS that contains the length of MATRIXNO field equals 8 (eight)

//oracle 9G.