Searching a string in a column

Hi All,
I have a table having a column containing names,i need to write a query that would fetch the exact string from the table.
eg. Available funcions- is the data in the table
Query: select name from <table> where LOWER(name) like LOWER('av%')
the query explained above will return the result : Available functions
instead of the LIKE clause do i have anyother effective way of searching the table??
thanks in advance
regards
Karthik

There is another method, but I do not know if it would be faster
I'll search for names that have MICHELLE
MY_TABLE:
NAME_IND
ABRAHAM MICHELLE LYNN
BATEY MICHELLE LYNN
CARR CRAIG MICHEAL
COTE BRUCE MICHEAL
ELDREDGE MICHEAL BRUCE XOX
FLINT MICHELLE LEIGH
FORSBERG JOHN MICHEAL JR
GESSFORD MICHELLE LANA
GREAUX MICHEL EDMOND
HAWLEY MICHELE LEE
HINDS KRISTY MICHELLE
JARRELL SHARIKA MICHELLEANN
JENNINGS MICHELLE DYAN
JONES MICHELLE LEE XOX
MICHEL BRIAN PATRICK
MICHEL CHARLES FREDERICK
MICHELS MARSHALL THOMAS
SHEARIN MICHELE LYNN
THOMAS MICHELL
WARNE MICHELLE MARIE
SELECT name_ind
   FROM My_Table
   WHERE 'MICHELLE' = SUBSTR( Name_Ind, INSTR(Name_Ind,'MICHELLE',1), LENGTH('MICHELLE') )RESULTS:
NAME_IND
ABRAHAM MICHELLE LYNN
BATEY MICHELLE LYNN
FLINT MICHELLE LEIGH
GESSFORD MICHELLE LANA
HINDS KRISTY MICHELLE
JARRELL SHARIKA MICHELLEANN
JENNINGS MICHELLE DYAN
JONES MICHELLE LEE XOX
WARNE MICHELLE MARIE

Similar Messages

  • Help required- Searching Particular string in column

    Hi,
    I have a table by name temp and 2 values in the table. I'm using LIKE caluse to search a string. I'm getting output for some particular string. Please correct the below query for me.
    I have given a table/data reference for you:
    Create table temp(col1 varchar2(255));
    insert into temp values ('Test_Scale_High');
    1 row inserted
    insert into temp values ('Test_Scale_High');
    1 row inserted
    commit;
    select * from temp;
    col1
    Test_Scale_High
    Test_Scale High
    select * from temp where upper(col1) like '%TEST_SCALE%';
    COL1
    Test_Scale_High
    Test_Scale High
    select * from temp WHERE UPPER(COL1) LIKE '%TEST_SCALE_%';
    COL1
    Test_Scale_High
    Test_Scale High
    select * from temp WHERE UPPER(COL1) LIKE '%TEST_SCALE_H%';
    No Row Selected
    Thanks,
    Santhosh.S

    santhosh.shivaram wrote:
    select * from temp;
    col1
    Test_Scale_High
    Test_Scale High
    select * from temp where upper(col1) like '%TEST_SCALE%';
    COL1
    Test_Scale_High
    Test_Scale High
    select * from temp WHERE UPPER(COL1) LIKE '%TEST_SCALE_%';
    COL1
    Test_Scale_High
    Test_Scale High
    If I understand your requirement correctly you need to escape the Wild Card '_'
    Hope the following code helps:
    SQL> set feedback on;
    SQL> SELECT * FROM TEMP
      2  /
    COL1
    Test_Scale_High
    Test_Scale High
    2 rows selected.
    SQL> SELECT *
      2    FROM temp
      3   WHERE UPPER (col1) LIKE '%TEST_SCALE%'
      4  /
    COL1
    Test_Scale_High
    Test_Scale High
    2 rows selected.
    SQL> SELECT *
      2    FROM temp
      3   WHERE UPPER (col1) LIKE '%TEST_SCALE\_%' ESCAPE '\'
      4  /
    COL1
    Test_Scale_High
    1 row selected.
    SQL> SELECT *
      2    FROM temp
      3   WHERE UPPER (col1) LIKE '%TEST_SCALE_H%'
      4  /
    COL1
    Test_Scale_High
    Test_Scale High
    2 rows selected.
    SQL> SELECT *
      2    FROM temp
      3   WHERE UPPER (col1) LIKE '%TEST_SCALE\_H%' ESCAPE '\'
      4  /
    COL1
    Test_Scale_High
    1 row selected.
    SQL>Regards,
    Jo
    Edited by: Joice John : Added 2 Sample Codes

  • Sql query for finding a string in a column of a table

    Hi All,
    I have an issue, I have gotten a string ie '1D USD PRIME' and I have access to oracle's dictionary tables and views such as (all_source, all_tab_cols etc), my requirement is to find which table' column holds my above mentioned string, so I mean both the table name and the column name, it could be that this string might exist in more than 1 table so I want all the tables that holds it.
    Regards
    Rahul

    Hi All,
    I think you misunderstood my question, so may be I didnt ask it properly, so here it is I am explaining in detail with an example.
    Suppose I have 10 users with 10 different user name's in a database and I am the 11th user as DBA, every 10 of these users have created some tables lets say 20 tables each by every user making a count of the total tables as 200, now lets say 10 of 200 tables has a column ie fname with value as 'rahul', I want to search the string 'rahul' from all the 200 tables that which of the tables contains this string along with the column name.
    I hope this time my question is clear, the point is I just know of a value and I dont know the table name and column name where it may actually residing, futher I want to search tables of other users as well.
    Regards
    Rahul

  • How to search a string in some folder.

    Hi ,
    In my application users will upload some pdf,xls files to server. files will be saved in server. From the front end can search on all files with some specific string. If that string is there in any of the file, user has to get link to download that file and the text just before and after that user string. Its like how we get in google. This type of search we need to implement, Could any one please let me know how to implement, any free API are there in java. Please its urgent, help on this.
    Thanks
    Mohan

    user594301 wrote:
    I have 2 columns in a table. entry_no and msg_txt. entry_no is number(12) and msg_txt is LONG. I want to search one string in msg_txt. How can I write a query for this ?You can't write a query for this. The only thinks you can do with a long in a query is put something in and take it out again - with diffiuclty, usually.
    You can write a PL/SQL function to do this for you if necessary. The function will have to perform the search directly if the long < 32760 bytes or use DBMS_SQL to break the LONG up into 32760 byte segments that can then be manually searched. If you are lucky someone has done this already and posted the code online. Either way the solution will be slow and probably painful to implement.
    If possible convert your data to a CLOB and use DBMS_CLOB to find the data you need.

  • Which option to use to search text in multiple table columns

    Hi, I have a case where I have 4 db tables. On the UI there is an option to search a keyword from some columns of these 4 tables.
    Table1 = summary, description are the columns user can search on
    Table2 = project_name is the column user can search on
    Table3 = need_by_date is the column user can search on
    Table4 = owner is the column user can search on
    On the UI, user can enter a keyword and check the columns they want to search on. Out of the above, they can check one column, or more, or all.
    My question is what is the best option to use oracle text search in this case.
    Option 1 = I create a procedure to select these columns and then create an index on this procedure. In this case, is there a way to specify
    which columns to search on?
    Option 2= Create 4 separate indexes on these table/columns and then query the columns which user has selected to search on.
    Any other better idea?

    Hi,
    multicolumn only works on columns in the same table.
    If you can also query just on one field, then an index per field will be preferable. If you query always on all the fields then the one index approach is good. For this last the options are:
    1. Use User_datastore, create a procedure and a dummy column
    2. Create a materialized view for the query and build an index on this materialized view
    3. Store the fields as an xml in the main table and index the xml column.
    The maintanance of options 1 and 3 are bigger, because you need triggers to be aware of an update. Option 2 and 3 will need more storage.
    Herald ten Dam
    http://htendam.wordpress.com

  • In report layout, can format a long string display as Column mode?

    Hi,
    Just want to check in report builder any way can format a long string into a column mode?
    Example: I have a field to hold 8000 character, and would like to print
    30 character in each line, when reach 50 line, then print in column i/o to print next page?
    Any idea ? Thanks a lot if you can share your experience with me.
    best Regards,
    Klnghau

    hi let say your field name is x
    then if your want it word wrap then it's simple just get one field and make it's vertical
    elasticity variable. and asign the field to it..
    but if you want your field to be displayed as
    first colunm and then beside continuation of that column but in 2nd one...
    then create 2 formula columns make your field legth been distributed half in each.
    so cf_1 is:
    decalre
    t varchar2(1510);
    begin
    if length(:x) > 1500
    t := substr(x, 1, 1500); -- as 30 x 50 = 1500
    else
    t := :x;
    end if;
    return t;
    so cf_2 is:
    decalre
    t varchar2(1510);
    begin
    if length(:x) > 1500
    t := substr(x, 1500, length(:x)-1500); -- as 30 x 50 = 1500
    else
    t := '';
    end if;
    return t;
    and then in design view
    field1 field2
    for field1 source is cf_1 and
    for field2 source is cf_2
    that's all
    Enjoy Oracle...

  • Warning - 1241024 - Possible string truncation in column #

    I am running the following command in a simple MaxL script, the output of which is sent to a text file:
    display variable App.DB.SubVar;
    The text file appears to have generated fine, with the substitution variable value displayed. However, the following warnings are returned each time from the stderr output. Should I be concerned? Is there any way to rectify this?
    WARNING - 1241024 - Possible string truncation in column 3.
    WARNING - 1241028 - Output column defined with warnings.
    WARNING - 1241024 - Possible string truncation in column 4.
    WARNING - 1241028 - Output column defined with warnings.

    Hi John,
    Many thanks for your response. The problem is a little confusing, as I cannot see how anything is being truncated here - indeed there are characters to spare! Could it be because the potential size of the substitution variable name is 320 bytes and the potential size of the substitution variable value is 256 bytes (11.1.2.1)? Could this be the cause of the warnings here?
    Adding "set column_width 10;" does not appear to remove the warnings either unfortunately. Do you please have any other thoughts on how I might remove the warnings? It might allay the fears of the client later on!
    James

  • Turning sql  string (with dynamic columns) into a pipelined function

    Hi guys,
    I was working on an apex report the other day, and wrote the sql below (for those who don't know apex well, in an apex report you can define the columns at runtime.) When I was finished, I said to myself: "It would be great to have a pipeline function with this capability." So, the idea would be to have a sql string where the columns are created dynamically, depending on input parameters - and then be able to use this sql everywhere (oracle reports, sqlplus) through a pipelined function.
    Here's the sql (simplified, of course, the data itself is actually not important - the LOOP is the key)
    declare
    v_sql varchar2(4000);
    begin
    v_sql := 'select client, ';
    for i in (select employee from company_employees_view where condition = pi_parameter order by 1) loop
    v_sql := v_sql || sum(decode(employee,''' || i.employee || ''', total)) "' || i.employee || '"';
    end loop;
    v_sql := v_sql || ', sum(total) "Total"';
    v_sql := v_sql || ' from company_employees_view group by client';
    end;
    This sql would result in a final product like:
    select client
    , sum(decode(employee,'John',total) "John"
    , sum(decode(employee,'Paul',total) "Paul"
    , sum(decode(employee,'George',total) "George"
    (and so on... this sql could have more or less columns depending on the input parameters of the function)
    from company_employees_view
    group by client;
    I have tried feeding this sql into a ref cursor and an object, but always received an "inconsistent datatypes" message.
    The object would be something like:
    create or replace object rt_employee as (total number);
    create or replace tt_employee as table of rt_employee;
    create or replace object rt_client as (
    client varchar2(100),
    employee tt_employee);
    create or replace tt_client as table of rt_client;
    (I am not paying too much attention to syntax here.)
    By the way, no hurry whatsoever, this is just for fun, take your time. I am using database XE with apex 2.1 and sql developer 1.2.
    Thanks, Roger

    This is the only solution I've ever seen to dynamic pipelined columns...
    How to pipeline a function with a dynamic number of columns?

  • How to use string as a column name

    Hello,
    I have a fn getField() that returns a column delimited string - amt1,amt2 . I want to use this string as the column name in a second query on table MASTER_AMT and get the values for amt1 and amt2...so when i try....
    select getField( 'NPC_NOYTG' ) FROM MASTER_AMT
    WHERE ACTI_CODE = 'NPOR';
    the o/p i get is...
    GETFIELD('NPC_NOYTG')
    AMT1,AMT2,AMT3
    instead of...
    AMT1 AMT2
    500 0
    that i require.
    Any ideas on how to convert the string returned to a column name?
    Thanks very much
    rgds

    Try this ....
    In SQL*PLUS
    SQL> var ref_c refcursor
    --- Then type the follwing at SQL prompt
    declare
    cursor cur is
    select column_name
    from user_tab_columns a,
         (select upper(getField( 'NPC_NOYTG')) fld FROM MASTER_AMT
         WHERE ACTI_CODE = 'NPOR') col_lst
    WHERE
    instr(chr(44) || col_lst.fld || chr(44),chr(44) || a.COLUMN_NAME || chr(44) ) > 0
    AND table_name = 'MASTER_AMT';
    v_str varchar2(1000):= ' ';
    begin
    for c in cur loop
    v_str := v_str || c.column_name || ',' ;
    end loop;
    v_str := substr(v_str,1,len(v_str)-1);
    open :ref_c for
    'select ' || v_str || ' from master_amt';
    end;      
    --- after executing the above block, type the following at SQL prompt
    SQL > print ref_c
    Please let me know if this works for you. This should for any number of columns returned by the function.
    Shakti
    (http://www.impact-sol.com)
    (Developers of Guggi Oracle)

  • Search a string with in some file and get the name of file

    i want to search a string in some files that are in a given directory and return the name of file having searched string.I am doing this with grep command as given below
    import java.io.*;
    public class linux_java {
    public static void main(String[] args) {
    try {
    String command = "find . | xargs grep -l Resolv /data2/opt/jakarta-tomcat-4.1.24/webapps/Oa/BOG/*.txt";
    final Process process = Runtime.getRuntime().exec(command);
    OutputStream os= process.getOutputStream();
    System.out.println("out put stream= " +os);
    PrintStream stdIn = new PrintStream(new BufferedOutputStream(process.getOutputStream()), true);
    System.out.println("Return code = " + stdIn);
    } catch (Exception e) {
    e.printStackTrace();
    i dont know how to get the name of file that are return by the execution of command through process object. Please send the code for the same

    thanks for your suggestion....
    i change the code but now it is giving error as /usr/bin/find incomplete syntax....but i am giving the right syntax....
    please confirm whether the syntax is correct...
    import java.io.*;
    import java.util.*;
    public class linux_java {
    public static void main(String[] args) {
    try {
    //String command = "ls -alt";
    String command = "find /data2/opt/jakarta-tomcat-4.1.24/webapps/Oa/BOG -type f -exec grep -sl 'Aggarwal' {} \\; 2>/dev/null";
    ///grep -l System test/*java
    System.out.println(" the command is"+command);
    final Process process = Runtime.getRuntime().exec(command);
    InputStream is = process.getErrorStream();
    InputStreamReader isr = new InputStreamReader(is);
    BufferedReader br = new BufferedReader(isr);
    String line="";
    System.out.println(" the BufferedReader is"+br.readLine());
    while ((line = br.readLine()) != null) {
    System.out.println(" the files are"+line);
    } catch (Exception e) {
    e.printStackTrace();
    }

  • How to search a string from the database?

    how to search a string from the database? starting with some character

    If you're trying to do this in a SELECT, you can use the LIKE verb in your WHERE clause.
    Here's an Example
      SELECT obj_name FROM tadir
        INTO prog
        WHERE pgmid = 'R3TR'
          AND object = 'PROG'
          AND obj_name LIKE 'Z%'.
    In this case it will select every row that obj_name starts with Z. 
    If you wanted to find every row that the field obj_name contains say... 'WIN'  you use LIKE '%WIN%'.
    Edited by: Paul Chapman on Apr 22, 2008 12:32 PM

  • How to Store Encrypted String into OracleDatabase Column(vacrchar2)

    Hi..
    I encountered an error while inserting a Encryted String into oracle column.. Error "Quoted String Doesn't terminated properly"
    But i wrote Query string correctly and using Datatypes as String and vacharchar2(2000) in java and oracle respectively..
    what i need to do?

    Hi,
    if your code compose the sql programmatically without bind variables i.e.:
    String sqlInsert="insert into table A(encrypted_column) values ('" + encryptedValue+ ')");
    then if the string encryptedValue contains a ' character you end up with a wrong sql statement
    if you encryped values is something like AAABB#??£££'AAA the corresponding sql is
    insert into table A(encrypted_column) values ('AAABB#??£££'AAA')
    which is not correct becaus of the ' in the middle of the string.
    Giovanni

  • Increasing the speed of searching a string in a file

    I have to search a String in a big ASCII-file and have to delete it. Now I wrote a program which opens the source file and a target file. I am reading each line from the source file, check it and write it into the target file. It is working fine but it is very slowly.
    I check each line with:
    if (line.equalsIgnoreCase("xxxxx")) { }
    How can I make it much faster.
    Thank you for your help!
    Arthur

    IO is an issue, but I've noticed that changing the case of strings is very slow, probably because in unicode is harder than in ASCII.
    If you could replace the equalsIgnoreCase method by one or more equals, you'll get benefits. If you can, I would try something like the following to minimize the equalsIgnoreCase invocations:
    // Supose you are looking for "abcd"
    if (line.charAt(0) == 'a' || line.charAt(0) == 'A') {
       if (line.equals("xxxxx")) { }
    }Try it and let us know if it worth the effort.

  • Is it possible to search for strings containing spaces and special characters?

    In our RoboHelp project, there are figures with text labels such as Figure 1, Figure 3-2, etc.
    When I search for "Figure 3" I get all pages containing "Figure" and "3", even if I surround it in quotes.  Similarly, searching for "3-2" treats the '-' character as a space and searches for all pages containing '3' or '2'.
    Is there a way to search for strings containing spaces and special characters?

    In that case I think the answer is no if you are using the standard search engine. However I believe that Zoom Search does allow this type of searching. Check out this link for further information.
    http://www.grainge.org/pages/authoring/zoomsearch/zoomsearch.htm
      The RoboColum(n)
      @robocolumn
      Colum McAndrew

  • How to insert a very long string into a column of datatype 'LONG'

    Can anyone please tell me how can I insert a very long string into a column of datatype 'LONG'?
    I get the error, ORA-01704: string literal too long when I try to insert the value into the table.
    Since it is an old database, I cannot change the datatype of the column. And I see that the this column already contains strings which are very long.
    I know this can be done using bind variables but dont know how to use it in a simple query.
    Also is there any other way to do it?

    Hello,
    To preserve formatting in this forum, please enclose your code output between \ tags. And when executing you code as a pl/sql or sql script
    include following lineset define off;
         Your code or output goes here
      \Regards
    OrionNet                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Maybe you are looking for

  • Kyle XY - Where is the rest of Season 2

    I've enjoyed watching Kyle XY and wondered why only half of season 2 is available Looks like I'm going to have now watch episodes 14-23 on netflix or does a mod know when BT are going to add them?

  • DDI or DDK for Yes/No dropdown

    Hi Simple one this... I require a number of dropdowns (15) for Yes/No options. Should I use a dropdownbyIndex or dropdownbykey. If I use a dropdownbykey, am I right in thinking that I can use a domain that has X and space for a value and the Yes/No d

  • Sharing & permissions = mixed access

    Hello, I am trying to unlock a bunch of files (pictures) so that I can delete duplicates.  When I right click and select get info, the box where I lock or unlock the filea won't unlock them even if I unclick "lock."  I am assuming that this is becaus

  • Collaboration Portal Transport Question

    I created a test collaboration room on an Netweaver 7.0 SPS 9 portal and created a tranport package with that content.  Now that the proof of concept is done, we decided that we will go live with the collobartion rooms on the Netweaver 7.0 SPS 19 lan

  • Get message "Outlook Calendar Synchronization failed"

    I hope someone can help. When I sync, the hotsync log gives me the following info. Everything syncs fine except the calendar won't sync. The message doesn't give me any info on why it won't sync (except maybe the words "Recovery sync" - not sure why