How do i return the count of matching characters in 2 string

hi guys,
is there any comparision function in oracle that return the number of matching character between 2 string ?
example - 'josephine' and 'johnny'
return 3 ('j','o' and 'n')
please advice,
Best Regards,
Noob

Hi,
Type creation:
CREATE TYPE t_character AS OBJECT
   v_character varchar2(1)
CREATE TYPE characterList AS TABLE OF t_character;
/Function creation:
CREATE OR REPLACE FUNCTION fnc_compare_string(p_string_1 IN VARCHAR2,
                                              p_string_2 IN VARCHAR2) RETURN VARCHAR2 IS
   RESULT  VARCHAR2(4000);
   v_list1 characterList := characterList();
   v_list2 characterList := characterList();
   v_first BOOLEAN := TRUE;
   c_separator CONSTANT VARCHAR2(1) := ',';
BEGIN
   FOR i IN 1 .. length(p_string_1) LOOP
      v_list1.EXTEND;
      v_list1(i) := t_character(substr(p_string_1,
                                       i,
                                       1));
   END LOOP;
   FOR i IN 1 .. length(p_string_2) LOOP
      v_list2.EXTEND;
      v_list2(i) := t_character(substr(p_string_2,
                                       i,
                                       1));
   END LOOP;
   FOR reg IN (SELECT DISTINCT *
                 FROM TABLE(CAST(v_list1 AS characterList))
               INTERSECT
               SELECT DISTINCT * FROM TABLE(CAST(v_list2 AS characterList))) LOOP
      IF v_first THEN
         v_first := FALSE;
         RESULT  := RESULT || reg.v_character;
      ELSE
         RESULT := RESULT || c_separator || reg.v_character;
      END IF;
   END LOOP;
   RETURN(RESULT);
END fnc_compare_string;Test:
Connected to Oracle Database 10g Express Edition Release 10.2.0.1.0
Connected as hr
SQL> select fnc_compare_string('post', 'most') from dual;
FNC_COMPARE_STRING('POST','MOS
o,s,t
SQL> select fnc_compare_string('post', 'jhon') from dual;
FNC_COMPARE_STRING('POST','JHO
o
SQL> select fnc_compare_string('post', 'was') from dual;
FNC_COMPARE_STRING('POST','WAS
s
SQL> select fnc_compare_string('post', 'w') from dual;
FNC_COMPARE_STRING('POST','W')
SQL> Regards,

Similar Messages

  • How do you return the number of Rows in a ResultSet??

    How do you return the number of Rows in a ResultSet? It's easy enough to do in the SQL query using COUNT(*) but surely JDBC provides a method to return the number of rows.
    The ResultSetMetaData interface provides a method for counting the number of columns but nothing for the rows.
    Thanks

    No good way before JDBC2.0. u can use JDBC2.0 CachedRowSet.size() to retrieve the number of rows got by a ResultSet.

  • I just upgraded on May 11 and find I cannot open a fold for bookmarks. I research and bookmarks are my lively hood. How can I return the bookmark functionality?

    MS 7 and long time user of Firefox so this is the recent upgrade of May 11. Unlike the prior bookmark functionality, I cannot indicate I want to bookmark a link and designate a new folder for a new topic in two to three clicks. This is critical to what I do for a living. How can I return the prior format and be sure bookmarks are backed up automatically. Does going back to the older and more functional tool bar restore this? And why does clicking the bookmarks toolbar show getting started, most visited and the printer icon? Getting started takes one to a new user set of instructions. But there are no functional operations in the tool bar? I am not going to go thru a lot of commands, this should be a automatic as before.

    '' the bookmark facility is not functional in 29 ... Bookmark puts all bookmarks there into "recently bookmarked" ''
    It does not.
    It works much the same as the old system does. Or at least it should do and does do for me.
    * Carefully reads the following article so you are certain what should be happening '''[[How to use bookmarks to save and organize your favorite websites ]]'''
    # From an unbookmarked page click the bookmarks star.
    #* That results in the bookmark being added, and yes initially it is just as an unsorted bookmark. (No doubt that is where most people put most bookmarks)
    # IMPORTANT click the star a second time. (But not so rapidly it counts as a doubleclick)
    #* You now have the options you had in the old version of Firefox <br /> Create new folders <br /> Save to a recently used folder <br /> Show all bookmark folders - and expand nested folders
    If your bookmarks are not working possibly the file is corrupted in which case see
    * http://kb.mozillazine.org/Bookmarks_history_and_toolbar_buttons_not_working_-_Firefox#Damaged_Places_database
    I am hoping it is just that you are doubleclicking the star too quickly.

  • How do I use the counter and digital signals of the 6071E while it is connected to SCXI modules?

    I am contemplating using a PCI 6071E with SCXI. We have the boards (6071E), we would need the cable (I suppose SH1006868) and the SCXI system. I would like to know how would you access the counter and digital line capabilities of the board. I will be using a SCXI-1314 with a SCXI-1520 Module for strain measurements but will need to use the counter and digital lines of the board as well. Can this be done? If so, how and/or what else do I need?

    I think this KnowledgeBase will answer the question for you.
    Accessing DAQ Board Counter Pins with an SCXI System
    Otis
    Training and Certification
    Product Support Engineer
    National Instruments

  • How can I return the current Date in Java?

    I am new to Java, and basically I want to know how I can return the current date as a variable, so for example, I have declared the following date variable
    private java.util.Date currentDate;How can I return the current date, do I have to write a method? To be more specific, I need to write a setMethod, that simply returns the current Date in Java.
    Please point me in the right direction.
    Thanks,

    If all you want is a date for printing or displaying, the easiest way is to use Date as shown below. If you need something more complex, look at the Calendar API.
    import java.util.Date;
    class DateEx
         public static void main(String args[])
              Date now = new Date();
              System.out.println(now);          
    }

  • TS1702 How can I return the app that I bought for my iPhone4S almost three months ago.

    How can I return the app I bought almost 3 months ago? Is this to late to return??

    Apps are not returnable. They're also very difficult to wrap.

  • How do you get  the count of number of  checkbox selected?

    hi,
    plz tell me how do you get the count of number of checkbox selected?

    Not sure what you are doing so I will attempt to answer your question. If have one question which can have multiple answers you have will recieve an array so you have to do getParameterValues("name") and move it into an array.
    If you have multiple questions and only value will be selected do a getParameter("name") on each form element.
    HTH, if not provide more detail.
    J.Clancey

  • How I can return the replication groups to be in the normal state again?

    Hi All,
    can anybody help me on the following issue:
    after executing "*exec dbms_repcat.suspend_master_activity(gname=>'RG_EARMS');*"
    I got the following and it rejected to resume the replication again:
    SQL>select job, what from dba_jobs where what like '%do_deferred_repcat_admin%' ;
    JOB WHAT
    31 dbms_repcat.do_deferred_repcat_admin('"RG_ELEDGER"', FALSE);
    34 dbms_repcat.do_deferred_repcat_admin('"RG_ETBR2"', FALSE);
    4 dbms_repcat.do_deferred_repcat_admin('"RG_COMMON_PROCS"', FALSE);
    55 dbms_repcat.do_deferred_repcat_admin('"RG_EFAST"', FALSE);
    7 dbms_repcat.do_deferred_repcat_admin('"RG_EFX"', FALSE);
    35 dbms_repcat.do_deferred_repcat_admin('"RG_ESTS"', FALSE);
    9 dbms_repcat.do_deferred_repcat_admin('"RG_ESCHEDULES"', FALSE);
    75 dbms_repcat.do_deferred_repcat_admin('"RG_EARMSG"', FALSE);
    32 dbms_repcat.do_deferred_repcat_admin('"RG_CSIUSER"', FALSE);
    155 dbms_repcat.do_deferred_repcat_admin('"RG_ETOOLS"', FALSE);
    10 rows selected.
    SQL>
    select gname, status from dba_repgroup;
    SQL>
    GNAME STATUS
    RG_ETBR2 NORMAL
    RG_COMMON_PROCS NORMAL
    RG_EFAST NORMAL
    RG_EARMS              QUIESCING
    RG_EFX NORMAL
    RG_ESTS NORMAL
    RG_ESCHEDULES NORMAL
    RG_EARMSG            QUIESCING
    RG_ELEDGER NORMAL
    RG_CSIUSER NORMAL
    RG_ETOOLS NORMAL
    11 rows selected.
    SQL> select id, gname, status, master, source, oname, request
    from dba_repcatlog
    order by gname, id;
    no rows selected
    the database version is 9.2.0.8.0
    the OS is SunSolaris 9
    so, how I can return the above groups to be in the normal state again?
    Thanks and Best Regards,
    Shereif
    Edited by: user642590 on Aug 6, 2009 8:13 PM

    I don't see an "dbms_repcat.do_deferred_repcat_admin('"RG_EARMS"') job.
    The RepGroup would be quiescing but not quiesced if there are active, uncomitted transactions.
    What is the error you get when you attempt to resume -- I guess that the groups are in the queiscing state ?

  • HOW DO i RETURN THE DOWNLOADED PHOTOSHOP ELEMENTS 12

    HOW DO I RETURN THE DOWNLOADED PHOTOSHOP ELEMENTS 12?

    Well, this is not the Elements forum, but…
    Unfortunately, only Adobe customer service can assist you with your issue. These are user forums; you are not addressing Adobe here.
    Click on the link below, and after that click on "Still need Help? Contact us."
    Then on the next page, click Chat
    There is also a phone option.
    http://helpx.adobe.com/contact.html?step=PHXS_downloading-installing-setting-up_licensing- activation
    © 2014 R_Kelly

  • How do I get the content to match when exporting pages document to word?

    How do I get the content to match when I export a pages document to word format?

    You simply cannot get an absolutely identical export, in any app to any app. Exporting from one app to another means converting/parsing code, therefore the result cannot be identical. In order to have control over your final result, use PDF export. If you need a closer compatibility with Word, use OpenOffice or LibreOffice. I would not bet that Word for Mac would presserve identical page setting if file is created in windows, or vice-versa.

  • Need quick help, please!!! How do I scan the counter and analog channel in parallel, synchronized?

    Hi,
    I'm using LabView6.1 and a PCI6014 DAQ card.
    I have to scan simultaneously an analog channel and the counter on the card. My project requires me to measure in parallel a force (a voltage on an analog channel) in correspondence to a distance (measured with a counter) and I have to display a force-distance graph.
    So, can someone please tell me how can I program the counter and an analog channel to take 1000 measurements in parallel, and then, by reading the buffers to have two sets of corresponding measurements?
    I've tried some things and I've got only an error message, that says that there is no free DMA channel available (the error comes from configuring
    the analog channel). I attached one of these programs that gives this error, maybe somebody can tell me what I do wrong.
    If somebody could send me an example (in LabView6, I have no 7 :-( ), I would be grateful.
    Thank you,
    pixooxiq
    Attachments:
    Scan_Test_4.vi ‏177 KB

    Hi pixooxiq,
    unfortunately, your Card has only one DMA-Channel.
    If you want to use two Channels simutaneously, you have to tell one of them to use an Interrupt instead.
    This option can be set with the "Set DAQ Device Information.VI"
    Just see the Bitmap, I've attached.
    Perhaps, you now get Performance-problems, cause the IRQ does not directly write the Data but involves the CPU. In this case the only possibillity is to use an other card with more than 1 DMA-Channel...
    Regards
    Peter Weber
    NI Germany
    Attachments:
    Interrupt2.bmp ‏159 KB

  • How do I return the VI path of a test step in LabVIEW?

    I'd like to create a VI that will return all the VI paths that are associated with the test steps in a TestStand sequence.  How do I return the VI path associated with a test step?  Below is a starting point that returns the first step in the sequence.
    Solved!
    Go to Solution.

    Thanks a lot, Allen.  Exactly what I was looking for.  Here is the code that worked:

  • How can I return the audio book which I never downloaded?

    How can I return the audio book which I never downloaded?

    All purchases are considered final whether or not you decide to download them, but you can try the 'report a problem' link to contact iTunes Support and see if they will credit or refund you : http://reportaproblem.apple.com
    If the 'report a problem' link doesn't work then you can try contacting iTunes support via this page : http://www.apple.com/support/itunes/contact/- click on Contact iTunes Store Support on the right-hand side of the page, then Purchases, Billing & Redemption

  • Hi there, I have much files saved on pages ( ios ipad) , I just open it today and did not find .all the files !!!! Just 4!!! Taken in consider that I did not delete or making any wrong action. How I can return the lost files!!!! Help please

    Hi there, I have much files saved on pages ( ios ipad) , I just open it today and did not find .all the files !!!! Just 4!!! Taken in consider that I did not delete or making any wrong action. How I can return the lost files!!!! Help please
    its very important files!

    tis true
    I know, I always do that but I was in a rush to get somewhere and I was relying on my thousand dollar Mac to do some kind of recovery or something. I know Microsoft always keeps temporary files (I think Mac does too, part of me asking here in this forum was for someone to tell me where I can find those files) and when you go to open Office Works then it gives you the option of opening the last recent documents, saved or not saved.
    I usually copy paste into my emial just in case something goes wrong with the created document but I just didn't have the time to login and do all that My loss, you live and you learn, BUT still if ANYONE got any info on this, PLEASE DO CHIME IN *keeping the hope alive*

  • HELP! Last second extra credit (before midnight), how can i return the node

    While traversing a tree... How can i return the node I am currently at?

    Or perhapspublic Node getCurrentNode() {
      return currentNode;
    }Your question has a large number of possible interpretations.

Maybe you are looking for

  • Converting cropped 4X3 video to native 16X9 in Final Cut Pro 5

    I short a short on the Panasonic DVX-100A in the cropped widescreen mode, which is essentially still a 4X3 image with black bars. I want to convert it to a native widescreen 16X9 file so I can transfer it to Beta for festivals. Does anyone know how t

  • Search results not showing certain apps in appstore!!??

    Hello, When I search for a certain app/game in the app store on my ipad, it does not come up in the results.. Have encountered this several times so far, who knows how long it has been like this.. PLEASE help? I have done  the simple little obvious t

  • Java crashes on a solaris 9 randomly with a core dump

    Hello Currently we are using JBoss Application server on solaris 9. Over a period of time. Java crashes suddenly. The condition under which this can be reproduced is currently not reproduceable. But over a period of time, this crash just happens. The

  • How to display a  User defined  symbol when using addLinearFeature

    Hi , We are displaying our DataBase spatial data in the form of image on to the browser . With the help of MapViewer mv.addLinearFeature i am able to draw lines on to it . I have created styles in MapBuilder for our userdefined symbols and added to M

  • Problem with CURR type field?

    Hi all, I have one ztable in which there is one field of type CURR of length 13.when i trying to read the value of this field through select statement the problem is as follows: SELECT SINGLE USR06 FROM PRPS INTO GV_SITE_CASH_LIMIT WHERE POSID = GV_S