Home » RDBMS Server » Server Administration » Re: Oracle Query - Mani
Re: Oracle Query - Mani [message #373908] Thu, 17 May 2001 02:27
GIRIDHAR KODAKALLA
Messages: 92
Registered: May 2001
Member
hai Mani,
I think i got the pl/sql code for your requirement.
Pls check this out and let me know whether it can help you
or not.

The table which i worked has one record.

SQL> select * from giri;

VALUE1 VALUE2
------------------------- -------------------------
ABCDEF ABC

And my PL/SQL code is as follows:

=================================
SQL> set serveroutput on
SQL> declare
2 myname1 giri.value1%type;
3 myname2 giri.value2%type;
4 len1 number := 0;
5 len2 number := 0;
6 len3 number := 0;
7 tempval number;
8 frac number;
9 begin
10 select length(value1) into len1 from giri;
11 select length(value1) into len1 from giri;
12 for i in 1..len1 loop
13 select instr(value1,substr(value2,i,1),1,1) into tempval from giri;
14 if tempval != 0 then
15 len3 := len3+1;
16 end if;
17 end loop;
18 frac := (len3/len1)*100;
19 dbms_output.put_line(frac);
20 end;
21 /
==================================
And the output is:-

50

PL/SQL procedure successfully completed.

HTH.

Cheers,
Giridhar Kodakalla
Previous Topic: how to fix ora-936 and ora-908
Next Topic: Re: Oracle Query - Mani
Goto Forum:
  


Current Time: Mon Dec 23 09:38:11 CST 2024