How to search a particular string in whole schema?

Hi Everyone,
My DB version is
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi
PL/SQL Release 10.2.0.1.0 - Production
"CORE 10.2.0.1.0 Production"
TNS for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
Suppose I have a column say "EMAIL_ID" in employee table. The employee name is "abcd" and his email_id is "[email protected]".
The column name is changing from "EMAIL_ID" to "EMAIL_ADDRESS" due to poor naming convention standard.
Now I've only one constant value i.e. "[email protected]"...So is there any way if I will write a query with this value and I'll get the list of
tables and the exact column name where this mail_id exists?
Regards,
BS2012.

create or replace
PROCEDURE value_search_db(p_string VARCHAR2,p_datatype VARCHAR2)
IS
S SYS_REFCURSOR;
CURSOR c_user_col IS
SELECT TABLE_NAME,COLUMN_NAME,DATA_TYPE FROM USER_TAB_COLUMNS,TAB
WHERE TABLE_NAME=TNAME AND TABTYPE='TABLE'
ORDER BY TABLE_NAME;
TYPE TAB_LIST
IS
  RECORD
    TABLE_NAME VARCHAR2(1000),
    COLUMN_NAME     VARCHAR2(1000),
    DATA_TYPE    VARCHAR2(100));
TYPE T_TAB_LIST
IS
  TABLE OF TAB_LIST;
  L_TAB_LIST T_TAB_LIST := T_TAB_LIST();
  L_STMT CLOB;
  l_exists NUMBER;
BEGIN
FOR i IN c_user_col LOOP
  L_TAB_LIST.EXTEND;
  L_TAB_LIST(L_TAB_LIST.LAST).TABLE_NAME := I.TABLE_NAME;
  L_TAB_LIST(L_TAB_LIST.LAST).COLUMN_NAME     := i.COLUMN_NAME;
  L_TAB_LIST(L_TAB_LIST.LAST).DATA_TYPE     := i.DATA_TYPE; 
END LOOP;
FOR i in 1..L_TAB_LIST.COUNT LOOP
    l_exists := NULL;
    IF L_TAB_LIST(I).DATA_TYPE = p_datatype THEN
      L_STMT := 'SELECT 1 FROM '||L_TAB_LIST(I).TABLE_NAME||' WHERE '
                  ||L_TAB_LIST(I).COLUMN_NAME||' LIKE ''%'||p_string||'%''';
      OPEN S FOR L_STMT;
      FETCH S INTO l_exists;
      CLOSE S;
      IF l_exists IS NULL THEN
      NULL;
      ELSE
        DBMS_OUTPUT.PUT_LINE('Table name: '||L_TAB_LIST(I).TABLE_NAME||'--Column Name: '||L_TAB_LIST(I).COLUMN_NAME);
        DBMS_OUTPUT.PUT_LINE(L_STMT);
      END IF;
    END IF;
END LOOP;
END value_search_db;
I t may help you.:-)

Similar Messages

  • How to search for particular string in array?

    I am struggling to figure out how to search array contents for a string and then delete the entry from the array if it is found.
    The code for a program that allows the user to enter up to 20 inventory items (tools) is posted below; I apologize in advance for it as I am also not having much success grasping the concept of OOP and I am certain it is does not conform although it all compiles.
    Anyway, if you can provide some assistance as to how to go about searching the array I would be most grateful. Many thanks in advance..
    // ==========================================================
    // Tool class
    // Reads user input from keyboard and writes to text file a list of entered
    // inventory items (tools)
    // ==========================================================
    import java.io.*;
    import java.text.DecimalFormat;
    public class Tool
    private String name;
    private double totalCost;
    int units;
      // int record;
       double price;
    // Constructor for Tool
    public Tool(String toolName, int unitQty, double costPrice)
          name  = toolName;
          units = unitQty;
          price = costPrice;
       public static void main( String args[] ) throws Exception
          String file = "test.txt";
          String input;
          String item;
          String addItem;
          int choice = 0;
          int recordNum = 1;
          int qty;
          double price;
          boolean valid;
          String toolName = "";
          String itemQty = "";
          String itemCost = "";
          DecimalFormat fmt = new DecimalFormat("##0.00");
          // Display menu options
          System.out.println();
          System.out.println(" 1. ENTER item(s) into inventory");
          System.out.println(" 2. DELETE item(s) from inventory");
          System.out.println(" 3. DISPLAY item(s) in inventory");
          System.out.println();
          System.out.println(" 9. QUIT program");
          System.out.println();
          System.out.println("==================================================");
          System.out.println();
          // Declare and initialize keyboard input stream
          BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
          do
             valid = false;
             try
                System.out.print(" Enter an option > ");
                input = stdin.readLine();
                choice = Integer.parseInt(input);
                System.out.println();
                valid = true;
             catch(NumberFormatException exception)
                System.out.println();
                System.out.println(" Only numbers accepted. Try again.");
          while (!valid);
          while (choice != 1 && choice != 2 && choice != 9)
                System.out.println(" Not a valid option. Try again.");
                System.out.print(" Enter an option > ");
                input = stdin.readLine();
                choice = Integer.parseInt(input);
                System.out.println();
          if (choice == 1)
             // Declare and initialize input file
             FileWriter fileName = new FileWriter(file);
             BufferedWriter bufferedWriter = new BufferedWriter(fileName);
             PrintWriter dataFile = new PrintWriter(bufferedWriter);
             do
                addItem="Y";
                   System.out.print(" Enter item #" + recordNum + " name > ");
                   toolName = stdin.readLine();
                   if (toolName.length() > 15)
                      toolName = toolName.substring(0,15); // Convert to uppercase
                   toolName = toolName.toUpperCase();
                   dataFile.print (toolName + "\t");
                   do
                      valid = false;
                      try
                         // Prompt for item quantity
                         System.out.print(" Enter item #" + recordNum + " quantity > ");
                         itemQty = stdin.readLine();
                         // Parse integer as string
                         qty = Integer.parseInt (itemQty);
                         // Write item quantity to data file
                         dataFile.print(itemQty + "\t");
                         valid=true;
                      catch(NumberFormatException exception)
                         // Throw error for all non-integer input
                         System.out.println();
                         System.out.println(" Only whole numbers please. Try again.");
                   while (!valid);
                   do
                      valid = false;
                      try
                         // Prompt for item cost
                         System.out.print(" Enter item #" + recordNum + " cost (A$) > ");
                         itemCost = stdin.readLine();
                         // Parse float as string
                         price = Double.parseDouble(itemCost);
                         // Write item cost to data file
                         dataFile.println(fmt.format(price));
                         valid = true;
                      catch(NumberFormatException exception)
                         // Throw error for all non-number input (integers
                      // allowed)
                         System.out.println();
                         System.out.println(" Only numbers please. Try again.");
                   while (!valid);
                   // Prompt to add another item
                   System.out.println();
                   System.out.print(" Add another item? Y/N > ");
                   addItem = stdin.readLine();
                   while ((!addItem.equalsIgnoreCase("Y")) && (!addItem.equalsIgnoreCase("N")))
                      // Prompt for valid input if not Y or N
                      System.out.println();
                      System.out.println(" Not a valid option. Try again.");
                      System.out.print(" Add another item? Y/N > ");
                      addItem = stdin.readLine();
                      System.out.println();
                   // Increment record number by 1
                   recordNum++;
                   if (addItem.equalsIgnoreCase("N"))
                      System.out.println();
                      System.out.println(" The output file \"" + file + "\" has been saved.");
                      System.out.println();
                      System.out.println(" Quitting program.");
            while (addItem.equalsIgnoreCase("Y"));
    // Close input file
    dataFile.close();
       if (choice == 2)
       try {
          Read user input (array search string)
          Search array
          If match found, remove entry from array
          Confirm "deletion" and display new array contents
       catch block {
    } // class
    // ==========================================================
    // ListToolDetails class
    // Reads a text file into an array and displays contents as an inventory list
    // ==========================================================
    import java.io.*;
    import java.util.StringTokenizer;
    import java.text.DecimalFormat;
    public class ListToolDetails {
       // Declare variable
       private Tool[] toolArray; // Reference to an array of objects of type Tool
       private int toolCount;
       public static void main(String args[]) throws Exception {
          String line, name, file = "test.txt";
          int units, count = 0, record = 1;
          double price, total = 0;
          DecimalFormat fmt = new DecimalFormat("##0.00");
          final int MAX = 20;
          Tool[] items = new Tool[MAX];
          System.out.println("Inventory List");
          System.out.println();
          System.out.println("REC.#" + "\t" + "ITEM" + "\t" + "QTY" + "\t"
                + "PRICE" + "\t" + "TOTAL");
          System.out.println("\t" + "\t" + "\t" + "\t" + "PRICE");
          System.out.println();
          try {
             // Read a tab-delimited text file of inventory items
             FileReader fr = new FileReader(file);
             BufferedReader inFile = new BufferedReader(fr);
             StringTokenizer tokenizer;
             while ((line = inFile.readLine()) != null) {
                tokenizer = new StringTokenizer(line, "\t");
                name = tokenizer.nextToken();
                try {
                   units = Integer.parseInt(tokenizer.nextToken());
                   price = Double.parseDouble(tokenizer.nextToken());
                   items[count++] = new Tool(name, units, price);
                   total = units * price;
                } catch (NumberFormatException exception) {
                   System.out.println("Error in input. Line ignored:");
                   System.out.println(line);
                System.out.print(" " + count + "\t");
                System.out.print(line + "\t");
                System.out.print(fmt.format(total));
                System.out.println();
             inFile.close();
          } catch (FileNotFoundException exception) {
             System.out.println("The file " + file + " was not found.");
          } catch (IOException exception) {
             System.out.println(exception);
          System.out.println();
       //  Unfinished functionality for displaying "error" message if user tries to
       //  add more than 20 tools to inventory
       public void addTool(Tool maxtools) {
          if (toolCount < toolArray.length) {
             toolArray[toolCount] = maxtools;
             toolCount += 1;
          } else {
             System.out.print("Inventory is full. Cannot add new tools.");
       // This should search inventory by string and remove/overwrite matching
       // entry with null
       public Tool getTool(int index) {
          if (index < toolCount) {
             return toolArray[index];
          } else {
             System.out
                   .println("That tool does not exist at this index location.");
             return null;
    }  // classData file contents:
    TOOL 1     1     1.21
    TOOL 2     8     3.85
    TOOL 3     35     6.92

    Ok, so you have an array of Strings. And if the string you are searching for is in the array, you need to remove it from the array.
    Is that right?
    Can you use an ArrayList<String> instead of a String[ ]?
    To find it, you would just do:
    for (String item : myArray){
       if (item.equals(searchString){
          // remove the element. Not trivial for arrays, very easy for ArrayList
    }Heck, with an arraylist you might be able to do the following:
    arrayList.remove(arrayList.indexOf(searchString));[edit]
    the above assumes you are using 1.5
    uses generics and for each loop
    [edit2]
    and kinda won't work it you have to use an array since you will need the array index to be able to remove it. See the previous post for that, then set the value in that array index to null.
    Message was edited by:
    BaltimoreJohn

  • How to search a special string in txt file and return it's position in txt file?

    How to search a special string in txt file and return it's position in txt file?

    I just posted a solution for a similar question here:  http://forums.ni.com/ni/board/message?board.id=170​&view=by_date_ascending&message.id=362699#M362699
    The top portion can search for the location of a string, while the bottom portion is to locate the position of a character.  Both can search for a character.
    The position of the character within the file is displayed in the indicator(s).
    R

  • How to search specific text/string in pdf files from command prompt?

    Hi,
    How to search specific text/string in pdf files from command prompt?
    Will be great if you can refer to any adobe provided command base utility to achieve the above target.
    Best Regards,

    You can't. The commandline parameters for Acrobat and Adobe Reader do not allow any type of commands to be run.

  • How to: Search for a string in entire movie project?

    I used a copyrighted name a few different places as I was creating a very long and complex game.  I have since removed it from the game where it was previously showing up but when I search the exe, it's still there in a few places.  Is there a way to search the entire movie project and all content, all scripts for a particular string?    For instance "Microsoft".
    If so, I cannot find a way and could use some direction, even if it's an xtra I need to install that adds this capability.
    Thanks!!!!!

    Scripts are easy. You open any script window and hit Ctrl + F and enter your search term in the Find box, ensuring the "All Casts" radio button is checked.
    For text and field members you'll need to write a script that does the search for you. If you were clearer about what you want to happen when you find your search term in a text member then someon could help you with how to perform this. I know there is already code posted to the forum somewhere about how to examine every member of every castLib checking the member type - which would be a very good place to start.

  • How to search for a string in ALL Function Modules source code

    Hello,
    I want to search for the string "HELLO" in all FUNCTION MODULES source code(FM, no reports/programs).
    Is this possible? How?
    Cheers,
    Andy

    hi,
    Execute RPR_ABAP_SOURCE_SCAN to search for a string in the code ... Press where-used-list button on the program which takes to the function group or the function module where it is used ..
    Regards,
    Santosh

  • How to search in particular node

    hi
    kindly tell how can we limit our search to a particular node instaed of the whole content
    thanks in advance

    Since it's all text, why not use a real quick Match Pattern (or Regular Expression, but you don't need that much power here), see attached.
    Cameron
    To err is human, but to really foul it up requires a computer.
    The optimist believes we are in the best of all possible worlds - the pessimist fears this is true.
    Profanity is the one language all programmers know best.
    An expert is someone who has made all the possible mistakes.
    To learn something about LabVIEW at no extra cost, work the online LabVIEW tutorial(s):
    LabVIEW Unit 1 - Getting Started
    Learn to Use LabVIEW with MyDAQ
    Attachments:
    Two-stage match demo.vi ‏8 KB

  • How to search for a string in a DefaultListModel

    I have a list of names stored in a DefaultListModel and would like to know how i can search for a particular name
    i assume i would have to use the method below but not sure of how to implement it
    so basically i would have a texfield where a user can type in a name to find in the list
    public int indexOf(Object elem)
    Searches for the first occurence of the given argument.
    Parameters:
    elem - an object.
    or i might be wrong
    Any ideas of how to write this mechanism
    Can anyone please help on this

    The DefaultListModel uses a Collection of some sort (Vector at present) to store data. You can get this data in two ways:
       DefaultListModel model = (DefaultListModel)list.getModel();
        Enumeration e = model.elements();
        while(e.hasMoreElements()) {
          if (e.nextElement().equals(elem)) return;
        }or
        Object[] array = model.toArray();
        for (int i = 0; i < array.length; i++) {
          if (array.equals(elem)) return;

  • How to search/split a string from visa read

    hello all, i have a string coming from the serial port... the pattern is:
    \00\s\s\s\s0,\s\s\s\s12,\s\s\s\s\s0,\s\s\s\s\s0\r\n
    where the data is read as 0, 12, 0 , 0. i would like to save this data into a Write to Measurement File, for which i have to convert this text data into decimal format. can anyone please suggest me how to reduce the data from the string? I know I can save the data in a text file, but i am limited to use the Write to Measurement FIle.vi
    please help.
    Now on LabVIEW 10.0 on Win7

    Hello LV_Enthu,
    Have you played around with the functions in the Functions palette>>String at all? There are a few helpful functions like search/split strings and match string pattern that can be helpful, but here is an example from our website as well that does just this. Please let me know if you have any further questions.
    Thank you,
    Deborah Y.
    LabVIEW Real-Time Product Marketing Manager
    Certified LabVIEW Architect
    National Instruments

  • How to search for a string

    Hi All,
    My requirement is to search string Like "List Price",if the input field is having this string at any place i need to transfer input value to target.
    Could any one help me on this writing a UDF for this.
    Input : Final List Price Vendor
    check for :List Price
    then pass the other values to Target.
    Thanks,
    Madhu

    Hi,
    Check with this UDF
    public String Search(String a,String b,Container container)
    String c;
    int i;
    i = a.indexOf(b);
    if(i == -1)
       c = " ";
    else
       c = a;
    return c;
    Here a is the input and b is the search string.
    0r
    if the value of search string doesnt change dynamically then the UDF can be like this
    public String Search(String a,Container container)
    String c;
    String b;
    b = "List price"
    int i;
    i = a.indexOf(b);
    if(i == -1)
       c = " ";
    else
       c = a;
    return c;
    Edited by: malini balasubramaniam on Aug 5, 2008 9:15 AM

  • How to search for exact string?

    Is there any way to search for the text string exactly as I enter it? Like 'exact search' in the OSS notes?
    For example, I'm trying to find the forum posts regarding the Excel 2007 file format XLSX. By XLSX the search finds hundreds of entries, but most of them are not even close. For example, this was one of the top results: /thread/1078918 [original link is broken]
    Why is it getting picked up when 'xlsx' doesn't even appear there? We are frequently complaining about the users who don't use search before posting, but, frankly, if it works like this, I can't blame them...

    >
    Jelena Perfiljeva wrote:
    > Why is it getting picked up
    >
    => https://forums.sdn.sap.com/search.jspa?threadID=&q=%22Whyisitgettingpicked+up%22&objID=f40&dateRange=all&numResults=15&rankBy=10001
    "Why is it getting picked up"
    I regularly use this to (re)find threads where I remembered a specific comment or even spelling mistake.
    Perhaps a better option in your case would be to use an AND between individual terms.
    I generally tend to edit the search string parameters directly, as it seems to cache previous results and do a search within a search. That might be an option for you as well though.
    Cheers,
    Julius
    Edited by: Julius Bussche on Jul 10, 2009 11:38 PM

  • How to search patttern in string

    hi to all experts,
    suppose i have string "CRTD REL OTEV URYR"
    i want to compare a variable with the string if the variable contains any of the following i have to process otherwise i have to discard
    i have coded this way but not working
    IF wa_head-status CP p_syst1.
        IF  p_p_kz_e1 = 'X'.
          del_flag = 1.
        ELSE.
          IF p_p_kz_e1 = ''.
            del_flag = 0.
          ENDIF.
        ENDIF.
    where wa_status is the string and comparing with p_syst1.

    Hello abdul,
    you can write your code like below :
    IF XYZ CA 'CRTDRELOTEVURYR'.
    then do this......your logic
    ENDIF.
    Hope it will solve your problem.
    Have a Nice Day.
    Regards,
    Sujeet

  • How to check a particular string in address

    hi,
    I need to check if my address has "freemans" or "foodstuffs or 'db.co.nz, then give a defautl email address. hence i coded like this
    zstmp_addr type ZCHAR60.
    IF ( ts_filerefs-zsmtp_addr CA 'foodstuffs' ) AND
           ( ts_filerefs-zsmtp_addr CA 'freemans' ) AND
           ( ts_filerefs-zsmtp_addr CA 'fremans' )  AND
           ( ts_filerefs-zsmtp_addr CA 'db.co.nz' ) .
        ts_filerefs-zsmtp_addr = 'mail123  ed.com'
    endif.
    This code works fine say if zsmtp_addr = Ben.shield  itcom , comes out of IF condition.
    But if I give zstmp_addr = jayasree.muthaiyan  it.com, goes in to IF condition ---> Error....
    why it goes inside this IF condition...is there any better coding for this ///
    thanks
    kinldy help

    Hi,
    And operator will not work in your case. And instead of CA use 'CS' operator. Refer below code.
    IF ( ts_filerefs-zsmtp_addr Cs 'foodstuffs' ) OR
    ( ts_filerefs-zsmtp_addr CS 'freemans' ) OR
    ( ts_filerefs-zsmtp_addr CS 'fremans' ) OR
    ( ts_filerefs-zsmtp_addr CS 'db.co.nz' ) .
    ts_filerefs-zsmtp_addr = 'mail123 ed.com'
    endif.
    Thanks,
    Archana

  • How to search a perticular column in a schema

    Hi All,
    Hope everyone doing good..!
    I need small help on Oracle please..
    I have schema called "IMGMIC" in the database and I have one column named "GELOC" in that.
    Now the problem is like how do i find out that column is exists(belongs to) in which table of that schema.
    I know only the column name & schema name name,but dont know from which table that column is.
    I wanted to check that column is belogs to which table.
    Please help the best way of searching of the column in detail...
    As i am getting this doubt no.of times....
    Thanks in ADV.
    mkr

    You can try one of these, depending on your privileges:
    select * from dba_tab_columns where owner = 'IMGMIC' and column_name = 'GELOC';
    select * from all_tab_columns where owner = 'IMGMIC' and column_name = 'GELOC';
    or connect as IMGMIC and:
    select * from user_tab_columns where column_name = 'GELOC';

  • How ca i search a particular word in mail

    can anybody please tell me how to search a particular word in mail
    Please mention the coding

    Message[] msgs = folder.search(new BodyTerm("word"));
    Note that no regular expressions are supported and "word" really means "substring".

Maybe you are looking for