Subject AW: [firebird-support] string difficulty
Author checkmail

Hi,

 

first, thank you!

 

But it should only delete the right *

 

For example, the ID is ABCDEFG, the interface will tell me ABCDEFG*********01 In this case, from right, all * should deleted.

 

But If the ID is ABC*DEFG, I get ABC*DEFG********01 and in this case only all * from right should be deleted.

 

I have create this, is there a simpler way?

 

  begin

    str = left(:str,16); -- only 16 digits, the other I don’t use here

    while (k = 1) do

    begin

      if(right(str, 1) = '*') then

      begin

        str = left(str,char_length(str)-1);

      end

      else

      begin

       teil = str;

       k = 0;

      end

    end

  end

 

 

Von: firebird-support@yahoogroups.com [mailto:firebird-support@yahoogroups.com]
Gesendet: Montag, 7. Dezember 2015 09:56
An: firebird-support@yahoogroups.com
Betreff: Re: [firebird-support] string difficulty

 

 

How can I get ABC*DEFG, leave the * between C*D, delete all * from right?



 

 

SET TERM ^ ;

CREATE PROCEDURE DEL_CHAR (

    M_SIR varchar(500),

    M_CHAR varchar(10) )

RETURNS (

    M_STR varchar(500) )

AS

    declare ii smallint; 

    declare iy smallint;

BEGIN

    m_str='';

    iy=char_length(m_sir);

    ii=1;

    while (ii<=iy) do

    begin

        if (position(substring(m_sir from ii for 1),m_char)=0) then

            m_str=m_str||substring(m_sir from ii for 1);

        ii=ii+1;

    end

END^

SET TERM ; ^

 

m_sir='ABC*DEFG'

m_char='*'