Finding columns names in a ResultSet

Hi,
Is it possible to get the columns names in a ResultSet ?
After a SQL query, while parsing the ResultSet List, I would like to detect the columns names used in the select processed. Is it possible ?

Hi,
Take a look at the method:
public ResultSetMetaData getMetaData() in the ResultSet.
/Kaj

Similar Messages

  • Finding column name in database

    Hi all..
    I want to find each column name, how many tables this column name is there
    in database.
    For single colum, i can find by using this query..
    select a.COLUMN_NAME, a.TABLE_NAME from all_tab_columns a where
    a.OWNER='DC_ERD' and a.COLUMN_NAME ='ACCESSORY_MAKER'
    If i want to find for each column present in the database, can anybody please tell
    me if it is possible in sql or pqsql is needed.
    Thanks in advance,
    Pal

    Are you asking about the number of tables, it's been used or the tables list?
    select column_name, count(table_name)
    from all_tab_columns
    group by column_nameCheers
    Sarma.

  • Finding Column Name for a Data Pattern

    Hi all,
    I want to find out all the column names which is having matching data pattern such as 'Football'
    I want to get all those column names whose data matches value 'FootBall'
    Which Data Dictionary i can find out column name with data value
    Pls advice
    Thanks

    Definitely a strange requirement but hey....
    SQL> ed
    Wrote file afiedt.buf
      1  declare
      2    cursor cur_tables is
      3      select table_name from user_tables order by 1;
      4    cursor cur_columns(p_table IN VARCHAR2) is
      5      select column_name from user_tab_columns
      6      where data_type IN ('CHAR', 'VARCHAR2')
      7      and table_name = p_table;
      8    v_cnt NUMBER;
      9    v_sep VARCHAR2(10);
    10    v_where VARCHAR2(2000);
    11    v_word VARCHAR2(30) := 'FOOTBALL';
    12  begin
    13    DBMS_OUTPUT.ENABLE(1000000);
    14    FOR t IN cur_tables
    15    LOOP
    16      v_sep := ' WHERE ';
    17      v_where := NULL;
    18      FOR c IN cur_columns(t.table_name)
    19      LOOP
    20        v_where := v_where||v_sep||c.column_name||' LIKE ''%'||v_word||'%''';
    21        v_sep := ' OR ';
    22      END LOOP;
    23      IF v_where IS NOT NULL THEN
    24        EXECUTE IMMEDIATE 'SELECT count(*) FROM '||t.table_name||v_where INTO v_cnt;
    25        IF v_cnt > 0 THEN
    26          DBMS_OUTPUT.PUT_LINE(v_word||' is in table '||t.table_name);
    27        END IF;
    28      END IF;
    29    END LOOP;
    30* end;
    SQL> /
    FOOTBALL is in table ADDRESS
    FOOTBALL is in table LOGTEXT
    FOOTBALL is in table NOMINAL
    PL/SQL procedure successfully completed.
    SQL>

  • How to find column names in a table

    Am learning the basics of SQL Plus.
    Have entered the following query:
    SELECT * FROM t_ebb_session;
    This gives me the following output.
    USER_ID SESSION_ID LAST_ACCE
    However LAST_ACCE is not the full name of the column as I get 'Invalid column name when I use it in a select statement.
    How do I display the full name?

    By default, SQL*Plus will set the column display width of a character column to its size in the database, and the heading will be the column name in uppercase, truncated to fit that width if necessary. (There is a different rule for numeric columns.)
    You can override this with the COLUMN command, e.g:
    COLUMN some_column_name FORMAT a30 HEADING "Alternative Name"
    Check out the SQL*Plus documentation for all the COLUMN options.

  • Find column name from constraint name

    How to fetch the column name from a constraint name to which the constraint is applied?.
    I only know the name of the constraint and can get the table name from "dba_constraints". How can I know to which column in the table this constraint is applied.
    Thanks

    What about this?
    satyaki>
    satyaki>
    satyaki>desc user_cons_columns;
    Name                                      Null?    Type
    OWNER                                     NOT NULL VARCHAR2(30)
    CONSTRAINT_NAME                           NOT NULL VARCHAR2(30)
    TABLE_NAME                                NOT NULL VARCHAR2(30)
    COLUMN_NAME                                        VARCHAR2(4000)
    POSITION                                           NUMBER
    satyaki>
    satyaki>Regards.
    Satyaki De.

  • Finding column Name in structure

    Hi All
    I have a requirement where i have the field names ( matnr, ekorg) etc., in an intenal table. eg., . using those names I need to read another internal table which carries values for the fields. I need to write a program to check if a particular field in table 1 has an initial value in table 2 or not.
    for my logic, I am looping on tab1( since it will contan only few fields) and assigning it to field symbols. but since the values from tab1 are dynamic, i cant hard code to assign field name like Matnr. So I am unable to figure out who to read tab2 with the field names i find in tab1.
    I used cl_abap_tabledescr=>describe_by_data (itab2) to columize the fields of itab2. but this method doesnt fetch me the field values? I was wondering if my approach was correct and if there is any way to use fields from itab1 to read values from itab2.
    I am not an ABAP expert, so any help is appreciated
    Regards
    Ruel

    Hi,
    You can use this to get the field values.
    ASSIGN COMPONENT <comp> OF STRUCTURE <s> TO <FS>.
    [Here|http://help.sap.com/saphelp_470/helpdata/en/fc/eb3923358411d1829f0000e829fbfe/content.htm] is the link to documentation.

  • Find column name in a package

    Hi,
    I am working in oracle 9i . I want to know the specified column (one) in the procedures that are availbale in the schema.
    For ex.
    If my schema contains 10 procdure means, i want to know the column (one) that are used in how many procedures..
    rgds...

    Like this?
    select * from user_source where upper(text) like '%YOUR_COLUMN%'

  • How to find column name for OIM attributes?

    What is the COLUMN_NAME for attributes "Password Generated" and "Design Console access" in OIM 11g?
    Also I cannot find FormMetaData.xml anywhere. Which file represents FormMetaData.xml in OIM11g?

    Thanks Rajiv.
    Here is what I got for the query,
    SELECT USR_EMP_TYPE FROM USR WHERE USR_FIRST_NAME = 'Test';
    USR_EMP_TYPE
    Consultant
    But Design Console Access is a CheckBox in UserForm for OIM 11g, doesnt this value has to be True/False?
    Please help me understand

  • Column name problem

    Hi all.... I have a little strange problem.. I hope you all can help me in solving this.
    for brief intro, I have an web application on MySQL written entirely in JAVA. Now we want to migrate from MySQL to Oracle... We have used Oracle Migration Workbench for migrating Schema and data. There is no problem uptill now.
    The real problem is with the column names... to clear the problem lets have an example...
    In mysql, if you execute[b] 'Select employeeID,empName from employee'  you will always get 'employeeID' and 'empName' column names in the resultset meta data... but if you executes the same query on oracle you will get 'EMPLOYEEID' and 'EMPNAME' column names in resultset meta data... then we make some xmls using these column names and then parse them and get values using HashMap... now in hashmap 'a' is different from 'A'... We did not take care of this problem while building this application. Now the application is almost completed and we are just one step away from migrating to Oracle but this problem is hindering us.
    just keep in mind there are several jsps,java beans, java services working on DB. So we need such a solution to apply on oracle and get our desired column names back from result set meta data.
    I have tried multiple solutions for this.
    1. Synonyms.. but you can only create synonyms for table not for column names
    2. Create table with double qoutes... but then we have to change all our queries which requires a lot of files to change.
    3. Create Views.... but it has same problem as of point 2.
    Can you suggest any better way to work around this problem... which require minimum effort and we migrate to oracle with existing code... Otherwise we have to do a lot of donkey work to change the code...
    Thanks in advance
    Message was edited by:
    user587592

    migrate to oracle with existing code... Otherwise we
    have to do a lot of donkey work to change the code...Is that not why SED/AWK/GREP and PERL were invented?
    As others have said, the SQL standard as well as several implementations do not support mixed- or camel-case identifiers. IN addition, only 8 character identifers are required, all else is 'above the standard'. You are facing a typical porting issue.

  • Finding source database table/column name for a column in a view

    Hi i need to be able to identify the original database table/column name for a column in a view.
    e.g. say i have a view like this
    create v1 as select a.name fname, b.name bname, c.name cname,......
    from u1.names a, u2.names b. u3.names c
    where .....
    Now I want to find out that the database table/column name for the fname, bname and cname columns in the view v1, which in this instance is u1.name.name, u2.names.name, u3.names.name.
    But i need to be able to do it for any view. Short of parsing the SQL is there an easy way of doing this?
    Now obviusly I can't do this for virtual columns but I will know my column is not virtual as it has an index on it.

    But i need to be able to do it for any view. Short of
    parsing the SQL is there an easy way of doing this?No, parsing the SQL is the only way. Good luck it is not something I would want to attempt.

  • How to find the column name and table name with a value

    Hi All
    How to find the column name and table name with "Value".
    For Example i have value named "Srikkanth" This value will be stored in one table and in one column i we dont know the table how to find the table name and column name
    Any help is highly appricatable
    Thanks & Regards
    Srikkanth.M

    2 solutions by Michaels (the latter is 11g upwards only)...
    michaels>  var val varchar2(5)
    michaels>  exec :val := 'as'
    PL/SQL procedure successfully completed.
    michaels>  select distinct substr (:val, 1, 11) "Searchword",
                    substr (table_name, 1, 14) "Table",
                    substr (t.column_value.getstringval (), 1, 50) "Column/Value"
               from cols,
                    table
                       (xmlsequence
                           (dbms_xmlgen.getxmltype ('select ' || column_name
                                                    || ' from ' || table_name
                                                    || ' where upper('
                                                    || column_name
                                                    || ') like upper(''%' || :val
                                                    || '%'')'
                                                   ).extract ('ROWSET/ROW/*')
                       ) t
    --        where table_name in ('EMPLOYEES', 'JOB_HISTORY', 'DEPARTMENTS')
           order by "Table"or
    SQL> select table_name,
           column_name,
           :search_string search_string,
           result
      from cols,
           xmltable(('ora:view("'||table_name||'")/ROW/'||column_name||'[ora:contains(text(),"%'|| :search_string || '%") > 0]')
           columns result varchar2(10) path '.'
    where table_name in ('EMP', 'DEPT')
    TABLE_NAME           COLUMN_NAME          SEARCH_STRING        RESULT   
    DEPT                 DNAME                ES                   RESEARCH 
    DEPT                 DNAME                ES                   SALES    
    EMP                  ENAME                ES                   JONES    
    EMP                  ENAME                ES                   JAMES    
    EMP                  JOB                  ES                   SALESMAN 
    EMP                  JOB                  ES                   SALESMAN 
    EMP                  JOB                  ES                   SALESMAN 
    EMP                  JOB                  ES                   PRESIDENT
    EMP                  JOB                  ES                   SALESMAN 
    9 rows selected.

  • Finding column and table name

    Hi,
    I need to find out that '101c_0000000018' value is which column and table of database.
    Is there a way to find it? I am looking for table and column which is storing this data.
    Thanks
    Sandy

    It's possible but performance is going to be horrible.
    Assuming the data is stored in a CHAR or VARCHAR2 column, something like
    DECLARE
      l_value VARCHAR2(100) := '101c_0000000018' ;
      l_cnt   PLS_INTEGER;
      l_sql    VARCHAR2(1000);
    BEGIN
      FOR x IN (
          SELECT table_name, column_name
            FROM dba_tab_cols
           WHERE owner = <<name of schema>>
             AND data_type IN ('CHAR', 'VARCHAR2' )
      LOOP
        l_sql := 'SELECT COUNT(*) FROM ' || x.owner || '.' || x.table_name || ' WHERE ' || x.column_name || ' = :1';
        EXECUTE IMMEDIATE l_sql
          INTO l_cnt
         USING l_value;
        IF( l_cnt > 0 )
        THEN
          dbms_output.put_line( 'Found the value ' || l_value || ' in owner = ' || x.owner || ' table name = ' || x.table_name || ' column name = ' || x.column_name );
        END IF;
      END LOOP;
    END;Justin
    Edited by: Justin Cave on Dec 8, 2011 12:20 PM

  • Column exist but ResultSet.getString(String) return invalid column name

    With oracle 7 db the ResultSet.getString(String) works fine but after the upgrade to oracle 8 db it return invalid column name. ResultSet.getString(int) method works fine.
    Is this a bug in the driver?
    Thanks
    -Reda

    Yes I'm 100 % sure that the columns exist.
    -RedaWell then maybe it's a bug in the Oracle driver. Lord knows it wouldn't be the first time that's happened.

  • "invalid column name" using resultset.getString()???

    I had a sql query against oracle db:
    select table1.field1, table1.field2, table2.field3
    from table1, table2
    where table1.field1=table2.field1;
    i got a valid resultset and i can enum the resultset by rs.getString(colnum). However, when i try to use rs.getString(table1.field1), i get a sql exception: "invalid column name". has anybody seen this before?
    TIA

    Hi,
    You can also modify your query and use the keyword "As" to give your fields another name :
    select user.name as userName, admin.name as adminName
    from user, admin
    rs.getString("userName");
    rs.getString("adminName");

  • Find the column name for a constraint

    Hi Guru,
    I know the constraint name, now i need the column name and table name for the constraint?
    Thanks

    Query the USER_CONS_COLUMNS  then you will find the column name and table Name
    SQL> Select  *  from  USER_CONS_COLUMNS  where Constraint_Name='<Your_constraint_Name>';

Maybe you are looking for

  • Issue returning a count of rows in a SELECT QUERY...

    I am working in Oracle 11.2g and I have a query where I want to return the count of DAILY records as well as WEEKLY records for specific marketers. Here is my query: Select     Mka_Mktr_No,            Case When Rat_Freq_Cd = 'D' Then Count(*) Else 0

  • How can I reset the arrows to go back and foreward

    The arrows in the upper left hand corner of the screen that lets you go back to the previous screen, and forward to another screen , are gone. How can I restore them?

  • Safari 5.1 keeps crashing - OSX 10.6.8

    Process:         Safari [192] Path:            /Applications/Safari.app/Contents/MacOS/Safari Identifier:      com.apple.Safari Version:         5.1 (6534.50) Build Info:      WebBrowser-75345000~1 Code Type:       X86-64 (Native) Parent Process:  la

  • Keep getting error 4002 when trying to update Genius

    I haven't seen anyone write about getting error 4002 when trying to update genius in itunes. I select update genius and it gathers information and sends it to the itunes store I assume. And then waits a few seconds and then I get the following messag

  • Update table using merge or Update statement

    Hi All, We have oracle 10G R2 On windows... We have tables BROK_DEALER_MAP and DTRMIS_REPORT. create table BROK_DEALER_MAP SL_NO NUMBER,      BROK_DLR_CODE VARCHAR2(30),      EMP_TAG     VARCHAR2(30), REMARKS     VARCHAR2(60), CONS_CODE VARCHAR2(30),