1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

search

Discussion in 'SQL PL/SQL' started by Rajarajan, Dec 13, 2014.

  1. Rajarajan

    Rajarajan Active Member

    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    55
    hi, i want get the suggestion for the string what i give.

    if i am giving some words like axample. i want that text to compare with the date i have in my table and give the nearest word "Did you mean example" like that

    Thanks & regards

    Rajarajan.M
     
  2. rajenb

    rajenb Forum Expert

    Messages:
    361
    Likes Received:
    114
    Trophy Points:
    655
    Location:
    Mauritius
    Hi,

    You can try:

    Code (SQL):
    SELECT <col_name> FROM <table_name> WHERE <col_name> LIKE '%example%';
    where <col_name> = your column name in table <table_name>
     
  3. ocprep

    ocprep Forum Advisor

    Messages:
    277
    Likes Received:
    76
    Trophy Points:
    410
    Location:
    Orlando, Florida
    It's not really clear what you are asking. I am assuming that where you have 'date' in your post, you meant 'data'. Starting with that assumption, I am going to guess even further. Let's say you have the following string value in a VARCHAR2 field in your table: "This is the string that I want to search for text".

    From your post, it seems that what you are asking for is a result that if you searched for 'xtring', the result would be "Did you mean to search for string?" This is called a fuzzy search. Oracle Text has the capability to perform it. You could probably create a Regular Expression search that approximated it. Google "Oracle fuzzy search" and do some research on it.
     
    Rajarajan likes this.
  4. Rajarajan

    Rajarajan Active Member

    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    55
    Sorry for my spelling you assumed correct that's what i exactly mean...... Thanks for the solution i will try that
     
  5. Rajarajan

    Rajarajan Active Member

    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    55
    Consider that i have a table 'raja_385' , it contains e_id,e_name as column and records

    10,'raja'
    20,'ramji'

    are the records in that table


    i write a pl/sql block for search the neat mach


    declare
    cursor c1 is
    select * from raja_385;
    begin
    for i in c1
    loop
    for j in 1..length(i.ename)
    loop
    IF REGEXP_LIKE(i.ename,substr('PRaja',j,LENGTH(i.ename))) THEN
    dbms_output.put_line(i.ename);
    exit;
    end if;
    end loop;
    end loop;
    end;




    Is this approach correct