Try to use UDF substr instead of substring.

I think it existed in 1.5

 

Regards,

 

Bogdan 

 

MordiCom d.o.o.

i...@mordicom.si

+386 (05) 33 00 360

 

From: firebird-support@yahoogroups.com 
[mailto:firebird-support@yahoogroups.com] 
Sent: Thursday, June 25, 2015 5:24 PM
To: firebird-support@yahoogroups.com
Subject: Re: [firebird-support] Soc Sec No comparison using Firebird

 

  

 

According to this I was correct - startpos and length must be integer literals

http://www.firebirdsql.org/refdocs/langrefupd15-substring.html

 

----- Original Message ----- 

From: 'Bogdan' bog...@mordicom.si [firebird-support] 
<mailto:bog...@mordicom.si%20[firebird-support]>  

To: firebird-support@yahoogroups.com 

Sent: Thursday, June 25, 2015 5:39 AM

Subject: RE: [firebird-support] Soc Sec No comparison using Firebird

 

  

create procedure social_number_comparison (

  i1 varchar(20),

  i2 varchar(20)

)

returns (

  result varchar(100)

)

as

declare variable x1 char(20);

declare variable x2 char(20);

declare variable e smallint;

declare variable e1 smallint;

declare variable e2 smallint;

declare variable i smallint;

begin

  i = 0; x1 = i1; x2 = i2; e = 0;

  while (i < 20 and e < 3) do

  begin

     i = i + 1;

     if (substring(x1 from i for 1) <> substring(x2 from i for 1)) then

        begin

           e = e + 1;

           if (e = 1) then e1 = i;

           else if (e = 2) then e2 = i;

        end

  end

  if (e = 0) then result = 'OK';

  else if (e = 3) then result = 'Not equal';

  else if (e = 1) then result = e1 || '. character ' || substring(i1 from i for 
1) || ' has changed';

  else

     begin

        if (substring(x1 from e1 for 1) = substring(x2 from e2 for 1) and

            substring(x1 from e2 for 1) = substring(x2 from e1 for 1)) then

            result = e1 || ' and ' || e2 || ' were swapped';

     end

  suspend;

end

Regards, 

Bogdan 

From: firebird-support@yahoogroups.com 
[mailto:firebird-support@yahoogroups.com] 
Sent: Wednesday, June 24, 2015 5:12 PM
To: Firebird Support
Subject: [firebird-support] Soc Sec No comparison using Firebird

  

 

Greetings All,

I would like to pass into a stored procedure two social security numbers for 
comparison and have the result tell me if one character has changed, or if two 
characters were switched or if it does not compare at all.  

Has anyone done anything like this they could share?  Or is it even possible?

Thoughts?

Thanks,

Mike

.  

  _____  


 <https://www.avast.com/antivirus> Avast logo

This email has been checked for viruses by Avast antivirus software. 
www.avast.com <https://www.avast.com/antivirus>  

 

  _____  


 <https://www.avast.com/antivirus> Avast logo

Ta e-pošta je bila pregledana z Avast protivirusnim programom. 
www.avast.com <https://www.avast.com/antivirus>  

 

 

  _____  


 <https://www.avast.com/antivirus> Avast logo

This email has been checked for viruses by Avast antivirus software. 
www.avast.com <https://www.avast.com/antivirus>  

 





---
Ta e-pošta je bila pregledana z Avast protivirusnim programom.
https://www.avast.com/antivirus
  • ... liviuslivius liviusliv...@poczta.onet.pl [firebird-support]
    • ... Helen Borrie hele...@iinet.net.au [firebird-support]
  • ... liviuslivius liviusliv...@poczta.onet.pl [firebird-support]
  • ... liviuslivius liviusliv...@poczta.onet.pl [firebird-support]
    • ... 'Softtech Support' stwiz...@att.net [firebird-support]
      • ... Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
        • ... 'Softtech Support' stwiz...@att.net [firebird-support]
      • ... 'Bogdan' bog...@mordicom.si [firebird-support]
        • ... 'Softtech Support' stwiz...@att.net [firebird-support]
        • ... 'Softtech Support' stwiz...@att.net [firebird-support]
          • ... 'Bogdan' bog...@mordicom.si [firebird-support]
            • ... 'Softtech Support' stwiz...@att.net [firebird-support]
              • ... 'Softtech Support' stwiz...@att.net [firebird-support]
    • ... Mark Rotteveel m...@lawinegevaar.nl [firebird-support]
  • ... liviuslivius liviusliv...@poczta.onet.pl [firebird-support]

Reply via email to