Stored procedure problem / work around?
Posted in 1999
Topics: Stored Procedures & SPL
Having a little problem at work with the 7.xx engin and 6xx tools:
I was trying to use a varibable in the text substring function in a stored
procedure: For your consideration:
create procedure test() returning char(1);define work_str char(15);
define x int;
define work_char char(1);
let work_str = "Hello World";
let x = 3;
let work_char = work_str[x];
end procedure;
Please excuse any typo/syntax errors in translation from memory.
Thanks in advance for any help!
John Leipold
Access Data Consulting Corporation
Chekcing the FAQ after I made the post (Dough!!) I found:
4.8.12 How do write a substr function in SPL?
On 11th May 1998 VFraenkle@cs-controlling.de (Volker Fraenkle) wrote:-
I knew, that there will be a substr function in INFORMIX 7.30. But my
Problem is, I need it for 7.22, 7.23.
With help of John H. Frantz (he developed base part of code), I can show you
a fine working substr SPL:
create procedure substr (sText varchar(255), iFPos smallint, iLen
smallint)
returning varchar(255);
define i smallint;
define sReturn varchar(255);
if iFPos > 1 then
for i = 1 to iFPos - 1 step 1
let sText = sText[2,255];
end for;
end if;
let sReturn = sText[1,1];
if iLen > 1 then
let sText = sText[2,255];
for i = 2 to iLen step 1
let sReturn = sReturn || sText[1,1];
let sText = sText[2,255];
end for;
end if;
return sReturn;
end procedure;
This shows the technique I was looking for.
John Leipold wrote in message <#ah66IHe#GA.211@upnetnews05>...
>Having a little problem at work with the 7.xx engin and 6xx tools:
>
>I was trying to use a varibable in the text substring function in a stored
>procedure: For your consideration:
>
>create procedure test() returning char(1);>define work_str char(15);
>define x int;
>define work_char char(1);
>
>let work_str = "Hello World";
>let x = 3;
>let work_char = work_str[x];
>
>end procedure;
>
>Please excuse any typo/syntax errors in translation from memory.
>
>
>Thanks in advance for any help!
>
>John Leipold
>Access Data Consulting Corporation
>
>
>
>