Subject | RE: [firebird-support] Soc Sec No comparison using Firebird |
---|---|
Author | Bogdan |
Post date | 2015-06-25T10:39:32Z |
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. |
Ta e-pošta je bila pregledana z Avast protivirusnim programom.
|