Possibility of Name [message #670599] |
Mon, 16 July 2018 03:07 |
Genesys
Messages: 45 Registered: August 2010
|
Member |
|
|
Hi,
have requirement to check the NAME in Block listed table(example base_table having world Block listed peoples name with alias , NAME and ALIAS are Columns).when new customer is going to create need to check the above table whether customer listed or not.
have written below PL/SQL Block to check the names.its working fine when NAME like 'AUGUSTO NAVARRO' or 'NAVARRO AUGUSTO' but I need suggesion if the the name having multiple string like 'AUGUSTO NAYA NAVARRO' as NAME so need the check possibility like 'AUGUSTO NAYA' or 'NAYA AUGUSTO' or 'AUGUSTO NAVARRO' or 'NAVARRO AUGUSTO' ...etc but i can extend the code to achieve this but performance wise its not good.can u please advise on this.
Note: base table having nearly 4 Millions of records.
declare
a varchar2(50) := 'AUGUSTO NAVARRO'; -- NAVARRO AUGUSTO
c number := 0;
d varchar2(50);
e varchar2(50);
p_name varchar2(50):='AUGUSTO NAVARRO';
cursor cur is(
SELECT
NAME
FROM base_table
WHERE UPPER(NAME) like UPPER(a)
);
begin
a := '%' || replace(a, ' ', '%') || '%';
dbms_output.put_line('name ' || a);
SELECT count(*)
into c
FROM base_table
WHERE UPPER(NAME) like UPPER(a)
AND RECORD_STAT = 'O';
if c = 0 then
d := substr(a, instr(p_name, ' ') + 1);
e := substr(a, 1, instr(p_name, ' ')+1);
dbms_output.put_line('first name ' || d);
dbms_output.put_line('second name ' || e);
a:=d || e;
--a := '%' || replace(a, ' ', '%') || '%';
dbms_output.put_line('full name ' || a);
end if;
for rec in cur loop
dbms_output.put_line(rec.name);
c := c + 1;
if c = 50 then
exit;
end if;
end loop;
end;
[mod-edit: code tags added by bb]
[Updated on: Fri, 27 July 2018 19:43] by Moderator Report message to a moderator
|
|
|