ResultSetMetaData.getColumnLabel(int coluN) gives column name with quote

I am using ojdbc14.jar for "Oracle Database 10g Enterprise Edition Release 10.2.0.3.0". My query is "Select 'column name' from dual". When i get column name using ResultSetMetaData.getColumnLabel(int coluN) it return column name including single quotes ie: for the above query result is 'columname'. Ideally it should not return ' (single quote).
Why do this happening?

You will have that even when you run with sqlplus.
=
Ashok

Similar Messages

  • Lookup column names with Power Query

    Hi,
    before I go ahead and change source files, I was wondering if I can use Power Query to get a model with the following data. To simplify the example, I have the following dataset in an Excel sheet:
    In another Excel sheet, the column names are defined, for example:
    What would like to have in Power Query is one table with the column names from the second screenshot in column B. Is there a way to link these two tables together in Power Query in order to use these names as column headers in the dataset?
    Thanks!
    - If a post answers your question, please click "Mark As Answer" on that post!

    You can filter the list of renames against the list of actual column names with something like
        FilteredColumns = Table.SelectRows(Columns, each List.Contains(Table.ColumnNames(Source), [Name])),
    Again, the working end-to-end:
    let
    Source = Table.FromRows({{"New York", 23, 51, 732}, {"Chicago", 25, 421, 23}, {"Los Angeles", 632, 22, 423}}, {"City", "Col 1", "Col 2", "Col 3"}),
    Columns = Table.FromRows({{"Col 1", "Column 1"}, {"Col 2", "Column 2"}, {"Col 3", "Column 3"}, {"Col 4", "Column 4"}}, {"Name", "Value"}),
    FilteredColumns = Table.SelectRows(Columns, each List.Contains(Table.ColumnNames(Source), [Name])),
    ColumnsAsRenames = Table.TransformRows(FilteredColumns, Record.FieldValues),
    RenamedColumns = Table.RenameColumns(Source, ColumnsAsRenames)
    in
    RenamedColumns

  • JTable column names with custom model

    I'm having problems with column names in a JTable which uses a custom model. For some reason, the colums are being shown as A, B, C etc. The data, however, displays fine.
    This is the code which constructs the table.
    MyTableModel tableModel = new MyTableModel(myArrayList);
      myTable = new JTable(tableModel);
      myTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
      myTable.setFillsViewportHeight(true);This is the class, MyTableModel
    class MyTableModel extends AbstractTableModel {
            private ArrayList<Account> data;
            private String[] colNames = {"", "Name","Type","Group","Created","Modified"};
            public MyTableModel(ArrayList<Account> data) {
                this.data = data;
            public int getRowCount() {
                return data.size();
            public int getColumnCount() {
                return 6;
            public Object getValueAt(int row, int col) {
                Account account = (Account)data.get(row);
                switch(col) {
                    case 0:
                        return account.getIcon();
                    case 1:
                        return account.getName();
                    case 2:
                        return account.getType();
                    case 3:
                        return account.getGroup();
                    case 4:
                        return account.getDateCreated();
                    case 5:
                        return account.getDateModified();
                    default:
                        return "";
            public String getColumName(int index) {
             System.out.println("N:"+colNames[index]);
                return colNames[index];
        }When the table is displayed, nothing's displayed to the console, but I'd have thought getColumnName would print the current column name. Am I missing something obvious?

    Oh great. I'll go back under my rock.
    Thanks =)

  • Invalid column name (with ojdbc)

    hi,
    I created a resultSet by executing query with more then one table in it. (left join)
    and now i want to getObject. so I execute resultSet.getObject("tablename.columnName")
    and I get this error "invalid column name".
    when i'm doing the same thing with MySQL it works fine.
    I don't want to do aliases for all the columns because there are too much of those.
    please help.
    thanks,
    asaf.

    that's not standard JDBC. You must use either the plain column name,
    or the column number. In cases where there are multiple columns with
    the same name you must use the column number for all but the first
    column with the same name.
    Joe Weinstein

  • Dynamic column name with SELECT INTO

    I am trying to build a function that derives a pay amount from a set of business rules. There are about 40 columns that hold various pay amounts and their column names are variations of 4 indicators (day shift, vs night shift, etc.) that I have to dynamically look up, ie here is the ID number and a timecard, now figure out which of the 40 fields to look up to get the pay amount.
    I can determine from the timecard and employee ID which field to look at, but I'm getting hung up with the syntax needed to construct and execute the statement inside the PL/SQL block. I need to RETURN the pay I extract using the function, and I can create the correct SQL statement, but the EXECUTE IMMEDIATE won't accept the SELECT INTO syntax.
    Can someone please suggest a solution? Here is the function:
    create or replace FUNCTION FN_GET_PAYRATE(tc in NUMBER, e in NUMBER, pc in VARCHAR2)
    RETURN NUMBER
    IS
    e_id NUMBER;
    tc_id NUMBER;
    pl_cd VARCHAR2(7);
    shft VARCHAR2(2);
    lvl VARCHAR2(2);
    typ VARCHAR2(2);
    e_typ VARCHAR2(4);
    proj NUMBER;
    hrly VARCHAR2(4);
    payrt NUMBER;
    var_col VARCHAR2(10);
    sql_select VARCHAR2(200);
    sql_from VARCHAR2(200);
    sql_where VARCHAR2(200);
    sql_and1 VARCHAR2(200);
    sql_and2 VARCHAR2(200);
    sql_and3 VARCHAR2(200);
    sql_orderby VARCHAR2(200);
    var_sql VARCHAR2(2000);
    BEGIN
    e_id := e;
    tc_id := tc;
    pl_cd := pc;
    SELECT NVL(SHIFT,'D') INTO shft
    FROM TS_TIMECARD_MAIN
    WHERE TIMECARD_ID = tc_id;
    --DBMS_OUTPUT.PUT_LINE('SHIFT= ' || shft);
    SELECT NVL(PAY_LVL, 1), NVL(PAY_TYPE, 'B'), NVL(RTRIM(EMP_TYPE), 'LHD'), NVL(PROJECT, 001)
    INTO lvl, typ, e_typ, proj
    FROM TS_EMPLOYEES
    WHERE EMP_ID = e_id;
    --DBMS_OUTPUT.PUT_LINE('Level= ' || lvl);
    --DBMS_OUTPUT.PUT_LINE('PAY_TYPE= ' || typ);
    --DBMS_OUTPUT.PUT_LINE('EMP_TYPE= ' || e_typ);
    --DBMS_OUTPUT.PUT_LINE('PROJECT= ' || proj);
    IF e_typ <> 'LHD' THEN
    hrly := 'H';
    ELSE
    hrly := '';
    END IF;
    IF proj <> 001 THEN
    var_col := shft || lvl || typ || hrly;
    --DBMS_OUTPUT.PUT_LINE('RATE COLUMN= ' || var_col);
    sql_select := 'SELECT NVL(' || var_col || ', .01) INTO payrt';
    sql_from := ' FROM TS_PAYRATES';
    sql_where := ' WHERE PROJECT_ID = ' || proj;
    sql_and1 := ' AND ACTIVE = 1';
    sql_and2 := ' AND JOB_TYPE = ' || CHR(39) || e_typ || CHR(39);
    sql_and3 := ' AND PILE_ID = ' || CHR(39) || pl_cd || CHR(39);
    var_sql := sql_select || sql_from || sql_where || sql_and1 || sql_and2 || sql_and3 || sql_orderby;
    DBMS_OUTPUT.PUT_LINE('SQL: ' || var_sql);
    EXECUTE IMMEDIATE var_sql;
    DBMS_OUTPUT.PUT_LINE('RATE= ' || payrt);
    RETURN payrt;
    ELSE
    DBMS_OUTPUT.PUT_LINE('ERROR');
    RETURN 1;
    END IF;
    END;
    I have alternately tried this:
    SELECT NVL(var_col,.01) into payrt
    FROM TS_PAYRATES
    WHERE PROJECT_ID = proj AND ACTIVE = 1
    AND JOB_TYPE = CHR(39) || e_typ || CHR(39)
    AND PILE_ID = CHR(39) || pl_cd || CHR(39);
    as a substitute for the EXECUTE IMMEDIATE block, but I can't seem to use a dynamic substitution for the column name.
    Any help would be greatly appreciated.

    That's the most difficult part - the error messages seem to indicate a problem with the SQL statement in its execution context, because I can take the SQL string by itself and it executes perfectly.
    Here are three variations:
    SELECT INTO
    select fn_get_payrate(21555, 30162, 15) from dual
    ERROR at line 1:
    ORA-00905: missing keyword
    ORA-06512: at "PEOPLENETIF.FN_GET_PAYRATE", line 60
    SQL: SELECT NVL(N4P , .01) INTO payrt FROM TS_PAYRATES WHERE PROJECT_ID = 701 AND ACTIVE = 1 AND JOB_TYPE = 'LHD' AND PILE_ID = '15'
    Without SELECT INTO  (returns NULL)
    SQL> select fn_get_payrate(21555, 30162, 15) from dual;
    FN_GET_PAYRATE(21555,30162,15)
    SQL: SELECT NVL(N4P , .01) FROM TS_PAYRATES WHERE PROJECT_ID = 701 AND ACTIVE = 1 AND JOB_TYPE = 'LHD' AND PILE_ID = '15'
    RATE=
    EXECUTE IMMEDIATE USING
    SQL> select fn_get_payrate(21555, 30162, 15) from dual;
    select fn_get_payrate(21555, 30162, 15) from dual
    ERROR at line 1:
    ORA-01006: bind variable does not exist
    ORA-06512: at "PEOPLENETIF.FN_GET_PAYRATE", line 61
    SQL: SELECT NVL(N4P , .01) FROM TS_PAYRATES WHERE PROJECT_ID = 701 AND ACTIVE = 1 AND JOB_TYPE = 'LHD' AND PILE_ID = '15'

  • SQL Query not working for column names with spaces

    Hi People..
    We have a strange situation wherein, the column name in the database table has a space inbetween like "Constant Name". While we write a JDBC statement code with the select query we get an exception for invalid syntax. It will help us in a great way if you have anything to inform us on this..
    Thanks
    Prabz

    Using case sensitive names and names with spaces in it is not a good practice.
    However, I believe the SQL standard accounts for this with quoted identifiers. I believe the syntax is
    . select "My Field1", "My Field2"
    . from "My Table'
    Have also seen the following although it might be MS Access specific.
    . select [My Field1], [My Field2]
    . from [My Table]

  • Need a Query that Returns both Column Name with Column Data

    Hi,
    Hope someone can assist quite quickly. I'm after a query that will return me both column name together with column data, i.e
    Table: APP_INFO
    COL1  - currently has the value of 10
    COL2  - currently has the value of 'HELLO'
    COL3  - currently has the value of 'QWERTY'
    COL4  - currently has the value of 2000Query I'm after is to return the following result set: [actual column name, actual column data]
    COL1,10
    COL2,'HELLO',
    COL3,'QWERTY'
    COL4,2000
    Any help would be much appreciated.
    Thanks.
    Tony.

    Like this ?
    SQL> select empno, ename, deptno from emp where deptno = 10;
         EMPNO ENAME          DEPTNO
          7782 CLARK              10
          7839 KING               10
          7934 MILLER             10
    SQL> select decode(t.id,1,'EMPNO',2,'ENAME',3,'DEPTNO') COLNAME,
      2  decode(t.id,1,to_char(empno),2,ename,3,deptno)
      3  from (select emp.*, rownum rn from emp
      4  where deptno = 10) emp, (select rownum id from dict where rownum <=3) t
      5  order by emp.rn, t.id
      6  /
    COLNAM DECODE(T.ID,1,TO_CHAR(EMPNO),2,ENAME,3,D
    EMPNO  7782
    ENAME  CLARK
    DEPTNO 10
    EMPNO  7839
    ENAME  KING
    DEPTNO 10
    EMPNO  7934
    ENAME  MILLER
    DEPTNO 10
    9 rows selected.Rgds.

  • How to replace part of column name with dynamic value

    I have the following construction in an update transaction:
    $upd_blg_user_usr->addColumn("report_1_user", "NUMERIC_TYPE", "VALUE", "{rsCatReport.id_report}");
    The dynamic value, {rsCatReport.id_report}, gets a url variable.
    I want this variable to replace the "1" in the column name "report_1_user". Something like this:
    $upd_blg_user_usr->addColumn("report_{rsCatReport.id_report}_user", "NUMERIC_TYPE", "VALUE", "{rsCatReport.id_report}");
    That construction, however, does not work. Prevents the page from loading. I've tried different constructions but have not hit one one that works.
    First, I'm not sure anything will work and second, if some different construction will work, I don't know what it is.
    Can anyone answer these questions. Thanks in advance for your help.

    What? Are you some kind of genius?
    Yes that works perfectly. Thanks as always!
    Here's the rationale. The same basic form appears on many different pages. The only difference among the forms is the outcome of submitting the form. The form on different pages takes you to a different download page and a database column is marked to signify that the user downloaded that form. For instance:
    report_1_usr
    report_2_usr
    report_3_usr
    And so forth...
    Up to now each form has had to include the url variable so the submit would take the user to the right download page and it has had to include a unique reference to the correct database column.
    Now I can echo or insert that url variable all over the place, including the reference to the column name in the transaction, so I can use a single instance of the form and include it on all pages.
    Thanks for helping me figure out the last step.

  • Site Index Portlet and Folder names with quotes

    Hi,
    I don't know if anyone else has hit this problem with the site index portlet, but it fails to render when the page group contains a page with a quote >'< in the page name.
    This is an issue particularly using O Drive and 10.1.4 portal, as the page name and page display name both get set to the folder name & windows alows quotes in folder names.
    The portlet code escapes the display name, but not the page URL. In 10.1.4 the URL has the page name in it, including any quotes, so the URL needs to be escaped too.
    This is achieved by modifying the code in site_index_tree.process_tree. Have a look how l_title_enc is set & do the same for the l_link value. l_link_enc := replace(l_link, '''', '\''');
    Comments and suggestions welcome.
    Cheers,
    David

    Hi
    to avoid this problem I'm afraid that you have to avoid quotes from your pages names.
    Quotes in URL are not supported by navigators so you can't use them for pages names (but,as you said you can use for display names).
    A possible workaround is to modify the render_tree method, replacing URL by permanent links.
    Your url http://myportal/page/portal/page/apage/anotherpage/namewithquote will be replaced by something like :
    http://myportal/page/portal/page/54564F654SD5F4SD56F4SD564FS
    Hope this will help

  • Display column name with Group by

    Hi,
    I am having a table with a column series which is repeating.
    When i want to get all the unique series and its count, in the normal sql, I am using
    select series,count(1) from temp_table group by series;
    But the same is not working in the case of SQLX,
    I want <root><series><name count="8">series1</name><name count="18">series2</name></series></root> kind of output.
    But when i use SQLX query,
    select XMLElement("root",XMLElement("series",XMLAgg(XMLElement("name", ... group by series
    it is returning more than one record.
    How to get the desired result??
    Thanks
    Guru

    I wanted to know whether it is possible to get the count in the sqlx itself, Can anybody point me to any SQLX query for that?

  • Content Type Column Names with same display Name ???

    Hi everyone,
    I have a SharePoint Sitecollection where are Site Column Display Names are the same (see Image)
    If I view the URL links, the internal names are different, that's ok.
    But how is this possible ? You can't rename the columns with existing names ?
    Thanks
    Stephan

    Like Enrique I would say these werent created via the interface. Doubt a migration would have done anything only Lookups seem to be duplicating. Could these be used in a form of some kind?
    If this is helpful please mark it so. Also if this solved your problem mark as answer.

  • Trying to list table column names with data type

    I have a list of table names and need to output the fields and their type.  So I tried the code below but getName() returns string even when I know the field is an int.  So I'm assuming I'm using the wrong function.  I looked at the output from getMethods() but I didn't see anything else that would return the information I want.  TIA.
    <cfset TableList = "accountingsettings,address,area,areasettings">
    <cfloop from="1" to="#Listlen(TableList)#" index="i">
    <cfquery datasource="axxerion" name="getTablename">
    select * from #Listgetat(TableList, i)#
    where 0<>0
    </cfquery>
    <cfset colHeaderNames = ArrayToList(getTablename.getColumnList())/>
    <cfoutput>
    <p><b>#Listgetat(TableList, i)# #getTablename.getMetaData().getColumnCount()#</b></p>
    <ul>
    <cfloop from="1" to="#Listlen(colHeaderNames)#" index="x">
    <cfdump var="#getMetaData(Listgetat(colHeaderNames,x)).getmethods()#">
    <li>#Listgetat(colHeaderNames,x)# #getMetaData(Listgetat(colHeaderNames,x)).getName()# </li>
    </cfloop>
    </ul>
    </cfoutput>
    </cfloop>
    Returns
    accountingsettings 22
    ID java.lang.String
    BINENTRYID java.lang.String
    CLIENTID java.lang.String
    CREATESYSTEMUSERID java.lang.String
    CREATETIME java.lang.String
    DEPRECIATIONYEARS java.lang.String
    POSTNOTAPPROVED java.lang.String
    REGIONID java.lang.String
    RESIDUALVALUE java.lang.String
    REVISION java.lang.String
    UPDATESYSTEMUSERID java.lang.String
    UPDATETIME java.lang.String
    DUPLICATEREFERENCES java.lang.String
    STRICTMODE java.lang.String
    CONSOLIDATEINVOICEITEMS java.lang.String
    AUTOACCOUNTINGPERIOD java.lang.String
    INVOICEDESCRIPTION java.lang.String
    POSTREQUIRED java.lang.String
    CONSOLIDATEOUTINVOICEITEMS java.lang.String
    PAYMENTDIFFERENCECATALOGITEMID java.lang.String
    ACCOUNTINGPERIODLENGTHCODE java.lang.String
    CREDITPAYMENTS java.lang.String

    So I'm assuming I'm using the wrong function. 
    You are using GetMetaData() incorrectly. It returns an array of structures. Cfloop through the returned array, and output the #name# and #typeName# keys.
    But .. if you only need the column metadata. Dan's suggestion of using cfdbinfo would seem more appropriate here.

  • LOV of column names with a report's custom column headings?

    I have a list ov values definition that looks like this:
    select column_name d, column_name r from all_tab_columns where table_name = 'DATABASE_LIST'
    I'd like to list the custom column headings from a report as d, rather than repeating the column_name. How can I do this?

    As Anton said, the best thing is to store your custom headings in a table so that you can use the table for your LOV as well as for your report headings.
    To use dynamic report headings, you can use the 'PL/SQL function body returning colon-delimited headings' feature on the Report Attributes page.
    So, if your report headings are stored in table t that function body can be
    declare
    l_headings varchar2(4000)
    begin
    for rec in (select heading from t) loop
       l_headings := l_headings||':'||rec.heading;
    end loop;
    return ltrim(l_heading,':');
    end;Hope this helps.

  • SQL Dev converts MS SQL to Oracle - issue with numeric prefix column name

    Hi,
    We're working on migrating MS SQL data into Oracle 10g. An issue we encountered is that some of MS SQL's tables have column names with numeric prefix like 1Q07, 2Q07, ..., 4Q08, and so on. The converted model as well as script can be created. But one thing I notice is that SQL Dev appends a prefix "A" for column names with numeric prefix. This makes sense because Oracle does not allow a column with number. But somehow this does not work with only 4Q
    1Q04 => A1Q01
    2Q07 => A2Q07
    3Q08 => A3Q08
    4Q08 => 4Q08 ???
    Why? Any place in the tool where I can override this?
    Obviously I can manually modify column name 4Q08 to A4Q08 in the script. But by doing this when moving data, it would fail because tool has no knowledge of updated column name.
    Thanks in advance.

    Hi ittichai,
    In <repository>.MIGRATION_TRANSFORMER body
    FUNCTION first_char_check(p_work NVARCHAR2) RETURN NVARCHAR2
    v_allowed := C_DISALLOWED_CHARS || '012356789_$';
    should be
    v_allowed := C_DISALLOWED_CHARS || '0123456789_$';
    If you make this change and convert the 4Q08 will be
    A4Q08 is expected, without any manual rename.
    -Turloch
    Message was edited by:
    Turloch O'Tierney

  • How to retrieve column names in a query in a case sensitive way

    Given a query, I want to extract all the column names/aliases in the query in a case-sensitive way.
    When I use dbms_sql.describe_columns() or java.sql.ResultSetMetaData classes getColumnName() or getColumnLabel()
    it returns the columns name ONLY in Upper case.
    My application needs to extract the column names in the same case as it appears in the query string.
    Is there any API to get this without parsing the SQL query string?
    Thanks
    PS: The dbms_sql.describe_columns() returns the column name in upper case.
    declare
    IS
    l_column_recs DBMS_SQL.DESC_TAB;
    l_cur NUMBER;
    l_column_count NUMBER;
    BEGIN
    l_cur := dbms_sql.open_cursor;
    dbms_sql.parse(l_cur, 'select target_type from targets', dbms_sql.NATIVE);
    dbms_sql.describe_columns(l_cur, l_column_count, l_column_recs);
    FOR i IN l_column_recs.FIRST..l_column_recs.LAST
    LOOP
    dbms_output.put_line(l_column_recs(i).col_name);
    end loop;
    end;
    /

    As far as the result set is concerned, though, the column name is in all upper case. If you query the data dictionary, you would see that the TARGET_TYPE column in the TARGETS table is stored in upper case.
    The way Oracle works is that column names that are not enclosed in double-quotes are converted to upper case in the data dictionary and elsewhere and then Oracle looks for the column name in the table definition. That is what allows Oracle to have case-insensitive identifiers unless a user specifies case-sensitive identifiers by enclosing the identifier in double quotes.
    If you changed the query to be
    SELECT target_type as "target_type"
      FROM targetsOracle should report the alias in a case sensitive fashion because you've now indicated that the alias should be treated as case sensitive.
    Justin

Maybe you are looking for

  • I cannot connect my iOS 5 iPod with my iTunes library. HELP PLEASE!!

    I conected it to the USB and to my computer and it only comes up as a camera. I am trying to transfer music from my laptop that has Windows Vista to my new iPod touch.

  • File name conflict in File Download filter in Policy Studio

    Hi, I am trying to use File Download filter to download the file from sftp server and saving it on local machine using Save to File filter. File format is ABC_MMDDYYYY,zip i need to get the name of the file at run time. what would be Attribute Select

  • Nav links not working in Blackberry

    I have put up some test pages for a client to view ( http://www.jescoconstruction.com/index2). When he is on his Blackberry, and he selects links from the navigation menu, he gets an error message which says it can't find the server for that page and

  • How i can add description tag in xml gallery

    my xml is.................... <?xml version="1.0" encoding="utf-8"?> <?xml-stylesheet href="xmldesign.css" type="text/css"?> <gallery thumb_width="400" thumb_height="290" gallery_width="400" gallery_height="700" gallery_x=" " gallery_y=" " full_x="12

  • Problem accessing VARRAY OF VARCHAR in 9i, but working in 8i

    The following code (modified sample ArrayExample.java for VARRAY OF VARCHAR) produces different results on a 8.1.7 and 9.0.1 database. The standard way of accessing the members of an array of strings in the database: ARRAY array = ((OracleResultSet)r