Subject | Re: Stored Proc to act like the string.Copy method in Delphi |
---|---|
Author | Ali Gökçen |
Post date | 2005-07-05T12:18:28Z |
Hi Martin,
what prevents you to use builtin substring function?
Regards..
Ali
--- In firebird-support@yahoogroups.com, "Martin Dew"
<martin.dew@a...> wrote:
what prevents you to use builtin substring function?
Regards..
Ali
--- In firebird-support@yahoogroups.com, "Martin Dew"
<martin.dew@a...> wrote:
> Can anyone help me with the following, I have a real problem atsite
> where a udf is leaking memory, and I would like to replace thefunctions
> of it by using a stored procedure instead, this basically involvesreturn a
> passing in a string, a start index and an end index, I want to
> string with the characters found from startindex to the endindexthrough
>
>
>
> Ie.
>
>
>
> DECLARE VARIABLE subStr VARCHAR(1024);
>
>
>
> subStr = Execute procedure '123456789', 1, 5;
>
>
>
> substr would now contain '12345'
>
>
>
> I have the starts of the proc, but have no idea how to iterate
> the provided string to be able to pick out a character each time.Can
> anyone help me ?
>
>
>
> CREATE PROCEDURE F_COPY (
>
> STR VarChar(1024),
>
> STARTINDEX Integer,
>
> ENDINDEX Integer)
>
> returns (
>
> COPYSTRING VarChar(1024))
>
> AS
>
> DECLARE VARIABLE Tmp VARCHAR(1024);
>
> DECLARE VARIABLE Pos INTEGER;
>
> BEGIN
>
> IF (Str IS NULL) THEN BEGIN
>
> CopyString = '';
>
> EXIT;
>
> END
>
>
>
> IF (StartIndex <= EndIndex) THEN BEGIN
>
> CopyString = '';
>
> EXIT;
>
> END
>
>
>
> Tmp = '';
>
> Pos = 0;
>
>
>
> WHILE (pos <= EndIndex) DO BEGIN
>
> Pos = Pos + 1;
>
> END
>
> END
>
>
>
> [Non-text portions of this message have been removed]