Professional Documents
Culture Documents
February 20 2009
A. Built-In Functions
LOCATE
The LOCATE function returns the starting position of the
first occurrence of one string (called the search-string) within
another string (called the source-string). If the search-string
is not found and neither argument is null, the result is zero. If
the search-string is found, the result is a number from 1 to the
actual length of the source-string. If the optional start is
specified, it indicates the character position in the source-
string at which the search is to begin.
//example of LOCATE function
SELECT RECEIVED, SUBJECT, LOCATE('GOOD', NOTE_TEXT)
FROM IN_TRAY WHERE LOCATE('GOOD', NOTE_TEXT) <> 0
LCASE
Returns a string in which all the characters have been
converted to lowercase characters
LEFT
The LEFT function returns the leftmost integer characters of
expression.
// Example of LEFT function
SELECT LEFT(NAME, FIRSTNAME_LEN)
FROM SYSIBM.SYSDUMMY1
Stored Procedure that uses user defined
B. Stored Procedure 1
Fx_LW(@cusName)
Stored Procedure 2
go
Stored Procedure 3
@indx = Fx_GetLastLetterIndex(@cusName)
@cusname = Fx_RemoveLastLetter(@cusName,@indx)
Example 1
Example 2