pos, vpos

Declaration

Integer function pos(cstring S1, cstring S2, Integer start, Integer Nth)

Integer function vpos(varchar S1, varchar S2, Integer start, Integer Nth)

Description

pos, vpos searches string S1 for string S2 starting at index start and looking for the Nth occurrence of S2. Pos and vpos return -1 for a string not found and -999999 for a bad input value;

Example Stored Procedure

CREATE PROCEDURE test_vchardel(S varchar(30), I Integer,C Integer)

RETURNS (result varchar(30)) AS

BEGIN

result = vchardel(S,I,C);

END!!

WISQL - calling the example stored procedure

execute procedure test_vpos("123123123123","23",1,1);

RESULT

==============================

1

execute procedure test_vpos("123123123123","12",1,1);

RESULT

==============================

3

execute procedure test_vpos("123123123123","12",0,1);

RESULT

==============================

0

execute procedure test_vpos("123123123123","12",1,1);

RESULT

==============================

3

execute procedure test_vpos("123123123123","12",0,4);

RESULT

==============================

9

execute procedure test_vpos("123123123123","12",0,5);

RESULT

==============================

-1

execute procedure test_vpos("123123123123","12",0,-5);

RESULT

==============================

-999999