Subject Re: [firebird-support] Substring Function
Author Helen Borrie
At 11:35 AM 10/10/2003 -0600, you wrote:
>Hello Folks,
>
>Using Firebird WI-V6.3.0.3815 Firebird 1.5 Release Candidate 6
>
>================================================
>
>CREATE PROCEDURE SUBSTRINGTEST (INPUT VARCHAR(12) )
>RETURNS (OUTPUT VARCHAR(12) )
>AS
>DECLARE VARIABLE I INTEGER;
>BEGIN
>I = 1;
>OUTPUT = '';
>WHILE (I <= 12) DO
> BEGIN
> OUTPUT = OUTPUT || SUBSTRING(INPUT FROM I);
> I = I + 1;
> SUSPEND;
> END
>END
>=================================================
>Errors off with
>ISC ERROR CODE:335544569
>
>ISC ERROR MESSAGE:
>Dynamic SQL Error
>SQL error code = -104
>Token unknown - line 10, char 43
>I
>=================================================
>Replacing the variable I in
>OUTPUT = OUTPUT || SUBSTRING(INPUT FROM I);
>with a constant like
>OUTPUT = OUTPUT || SUBSTRING(INPUT FROM 2);
>works, but of course doesn't render the desired results.
>
>Any idea's ?

As currently implemented, the substring function needs constants as
arguments. However, you can achieve what you want with EXECUTE STATEMENT
(documentation in release notes!)

h