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] 
  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



  .  




------------------------------------------------------------------------------


       This email has been checked for viruses by Avast antivirus software. 
        www.avast.com 
       







------------------------------------------------------------------------------
          Ta e-pošta je bila pregledana z Avast protivirusnim programom. 
        www.avast.com 
       



  

---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
  • ... Helen Borrie hele...@iinet.net.au [firebird-support]
  • ... 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