Dual Case Column names fail in select ORDER BY clause

This one is solved, but I thought someone might be able to explain why it happens.
I'm a newbie, since I just downloaded Oracel XE last night, and am trying it out.
I set up a trivial table with 4 text columns. As it happened, I used dual case for some of my column names, such as 'Nickname'.
When trying out the Query Builder, the Select statement failed whenever I added a sort.
After some head scratching and back-and-forth with the sample data base (HR), I finally renamed all the columns to upper case. (e.g. column 'Nickname' became 'NICKNAME'). Then it works.
Seems like a bug, but maybe it's just a feature. Here's the code generated by the Query Builder. As you can see, there are no quotes around the Table name or column names in the ORDER BY clause (and the dual case version of the column name works if I put the quotes in manually and run it with SQL command.) Seems quirky.
select     "TEAMS"."NICKNAME" as "NICKNAME",
     "TEAMS"."CITY" as "CITY",
     "TEAMS"."DIVISION" as "DIVISION",
     "TEAMS"."CONFERENCE" as "CONFERENCE"
from     "TEAMS" "TEAMS"
order by TEAMS.NICKNAME ASC

Welcome to forum. :)
Now, answering your question - no i don't think this is a bug.
It is your code - which create this bug.
Now, question is - what happen?
Just check your select and from clause. You put all the names are in double quote. When you put anything within double quotes - it become a case sensitive. So, the problem occurs there.
Let's see ->
satyaki>
satyaki>select * from v$version;
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
PL/SQL Release 10.2.0.3.0 - Production
CORE    10.2.0.3.0      Production
TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
NLSRTL Version 10.2.0.3.0 - Production
Elapsed: 00:00:01.11
satyaki>
satyaki>create table s_otn
  2      (
  3        id    number(4)
  4      );
Table created.
Elapsed: 00:00:02.14
satyaki>
satyaki>set lin 80
satyaki>
satyaki>desc s_otn;
Name                                      Null?    Type
ID                                                 NUMBER(4)
satyaki>
satyaki>desc S_OTN;
Name                                      Null?    Type
ID                                                 NUMBER(4)
satyaki>
satyaki>desc s_OtN;
Name                                      Null?    Type
ID                                                 NUMBER(4)
satyaki>
satyaki>drop table s_otn;
Table dropped.
Elapsed: 00:00:05.22
satyaki>
satyaki>
satyaki>create table "S_otn"  
  2       (
  3         id     number(4)
  4       );
Table created.
Elapsed: 00:00:00.12
satyaki>
satyaki>
satyaki>desc S_otn;
ERROR:
ORA-04043: object S_otn does not exist
satyaki>
satyaki>desc S_OTN;
ERROR:
ORA-04043: object S_OTN does not exist
satyaki>
satyaki>desc s_otn;
ERROR:
ORA-04043: object s_otn does not exist
satyaki>
satyaki>desc "S_OTN";
ERROR:
ORA-04043: object "S_OTN" does not exist
satyaki>
satyaki>desc "S_otn";
Name                                      Null?    Type
ID                                                 NUMBER(4)
satyaki>Got me?
Regards.
Satyaki De.

Similar Messages

  • How to pull only column names from a SELECT query without running it

    How to pull only column names from a SELECT statement without executing it? It seems there is getMetaData() in Java to pull the column names while sql is being prepared and before it gets executed. I need to get the columns whether we run the sql or not.

    Maybe something like this is what you are looking for or at least will give you some ideas.
            public static DataSet MaterializeDataSet(string _connectionString, string _sqlSelect, bool _returnProviderSpecificTypes, bool _includeSchema, bool _fillTable)
                DataSet ds = null;
                using (OracleConnection _oraconn = new OracleConnection(_connectionString))
                    try
                        _oraconn.Open();
                        using (OracleCommand cmd = new OracleCommand(_sqlSelect, _oraconn))
                            cmd.CommandType = CommandType.Text;
                            using (OracleDataAdapter da = new OracleDataAdapter(cmd))
                                da.ReturnProviderSpecificTypes = _returnProviderSpecificTypes;
                                //da.MissingSchemaAction = MissingSchemaAction.AddWithKey;
                                if (_includeSchema == true)
                                    ds = new DataSet("SCHEMASUPPLIED");
                                    da.FillSchema(ds, SchemaType.Source);
                                    if (_fillTable == true)
                                        da.Fill(ds.Tables[0]);
                                else
                                    ds = new DataSet("SCHEMANOTSUPPLIED");
                                    if (_fillTable == true)
                                        da.Fill(ds);
                                ds.Tables[0].TableName = "Table";
                            }//using da
                        } //using cmd
                    catch (OracleException _oraEx)
                        throw (_oraEx); // Actually rethrow
                    catch (System.Exception _sysEx)
                        throw (_sysEx); // Actually rethrow
                    finally
                        if (_oraconn.State == ConnectionState.Broken || _oraconn.State == ConnectionState.Open)
                            _oraconn.Close();
                }//using oraconn
                if (ds != null)
                    if (ds.Tables != null && ds.Tables[0] != null)
                        return ds;
                    else
                        return null;
                else
                    return null;
            }r,
    dennis

  • Using column number inplace of column name in SQL Select statement

    Is there a way to run sql select statements with column numbers in
    place of column names?
    Current SQL
    select AddressId,Name,City from AddressIs this possible
    select 1,2,5 from AddressThanks in Advance

    user10962462 wrote:
    well, ok, it's not possible with SQL, but how about PL/SQL?As mentioned, using DBMS_SQL you can only really use positional notation... and you can also use those positions to get the other information such as what the column is called, what it's datatype is etc.
    CREATE OR REPLACE PROCEDURE run_query(p_sql IN VARCHAR2) IS
      v_v_val     VARCHAR2(4000);
      v_n_val     NUMBER;
      v_d_val     DATE;
      v_ret       NUMBER;
      c           NUMBER;
      d           NUMBER;
      col_cnt     INTEGER;
      f           BOOLEAN;
      rec_tab     DBMS_SQL.DESC_TAB;
      col_num     NUMBER;
      v_rowcount  NUMBER := 0;
    BEGIN
      -- create a cursor
      c := DBMS_SQL.OPEN_CURSOR;
      -- parse the SQL statement into the cursor
      DBMS_SQL.PARSE(c, p_sql, DBMS_SQL.NATIVE);
      -- execute the cursor
      d := DBMS_SQL.EXECUTE(c);
      -- Describe the columns returned by the SQL statement
      DBMS_SQL.DESCRIBE_COLUMNS(c, col_cnt, rec_tab);
      -- Bind local return variables to the various columns based on their types
      FOR j in 1..col_cnt
      LOOP
        CASE rec_tab(j).col_type
          WHEN 1 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000); -- Varchar2
          WHEN 2 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_n_val);      -- Number
          WHEN 12 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_d_val);     -- Date
        ELSE
          DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);  -- Any other type return as varchar2
        END CASE;
      END LOOP;
      -- Display what columns are being returned...
      DBMS_OUTPUT.PUT_LINE('-- Columns --');
      FOR j in 1..col_cnt
      LOOP
        DBMS_OUTPUT.PUT_LINE(rec_tab(j).col_name||' - '||case rec_tab(j).col_type when 1 then 'VARCHAR2'
                                                                                  when 2 then 'NUMBER'
                                                                                  when 12 then 'DATE'
                                                         else 'Other' end);
      END LOOP;
      DBMS_OUTPUT.PUT_LINE('-------------');
      -- This part outputs the DATA
      LOOP
        -- Fetch a row of data through the cursor
        v_ret := DBMS_SQL.FETCH_ROWS(c);
        -- Exit when no more rows
        EXIT WHEN v_ret = 0;
        v_rowcount := v_rowcount + 1;
        DBMS_OUTPUT.PUT_LINE('Row: '||v_rowcount);
        DBMS_OUTPUT.PUT_LINE('--------------');
        -- Fetch the value of each column from the row
        FOR j in 1..col_cnt
        LOOP
          -- Fetch each column into the correct data type based on the description of the column
          CASE rec_tab(j).col_type
            WHEN 1  THEN DBMS_SQL.COLUMN_VALUE(c,j,v_v_val);
                         DBMS_OUTPUT.PUT_LINE(rec_tab(j).col_name||' : '||v_v_val);
            WHEN 2  THEN DBMS_SQL.COLUMN_VALUE(c,j,v_n_val);
                         DBMS_OUTPUT.PUT_LINE(rec_tab(j).col_name||' : '||v_n_val);
            WHEN 12 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_d_val);
                         DBMS_OUTPUT.PUT_LINE(rec_tab(j).col_name||' : '||to_char(v_d_val,'DD/MM/YYYY HH24:MI:SS'));
          ELSE
            DBMS_SQL.COLUMN_VALUE(c,j,v_v_val);
            DBMS_OUTPUT.PUT_LINE(rec_tab(j).col_name||' : '||v_v_val);
          END CASE;
        END LOOP;
        DBMS_OUTPUT.PUT_LINE('--------------');
      END LOOP;
      -- Close the cursor now we have finished with it
      DBMS_SQL.CLOSE_CURSOR(c);
    END;
    SQL> exec run_query('select empno, ename, deptno, sal from emp where deptno = 10');
    -- Columns --
    EMPNO - NUMBER
    ENAME - VARCHAR2
    DEPTNO - NUMBER
    SAL - NUMBER
    Row: 1
    EMPNO : 7782
    ENAME : CLARK
    DEPTNO : 10
    SAL : 2450
    Row: 2
    EMPNO : 7839
    ENAME : KING
    DEPTNO : 10
    SAL : 5000
    Row: 3
    EMPNO : 7934
    ENAME : MILLER
    DEPTNO : 10
    SAL : 1300
    PL/SQL procedure successfully completed.
    SQL> exec run_query('select * from emp where deptno = 10');
    -- Columns --
    EMPNO - NUMBER
    ENAME - VARCHAR2
    JOB - VARCHAR2
    MGR - NUMBER
    HIREDATE - DATE
    SAL - NUMBER
    COMM - NUMBER
    DEPTNO - NUMBER
    Row: 1
    EMPNO : 7782
    ENAME : CLARK
    JOB : MANAGER
    MGR : 7839
    HIREDATE : 09/06/1981 00:00:00
    SAL : 2450
    COMM :
    DEPTNO : 10
    Row: 2
    EMPNO : 7839
    ENAME : KING
    JOB : PRESIDENT
    MGR :
    HIREDATE : 17/11/1981 00:00:00
    SAL : 5000
    COMM :
    DEPTNO : 10
    Row: 3
    EMPNO : 7934
    ENAME : MILLER
    JOB : CLERK
    MGR : 7782
    HIREDATE : 23/01/1982 00:00:00
    SAL : 1300
    COMM :
    DEPTNO : 10
    PL/SQL procedure successfully completed.
    SQL> exec run_query('select * from dept where deptno = 10');
    -- Columns --
    DEPTNO - NUMBER
    DNAME - VARCHAR2
    LOC - VARCHAR2
    Row: 1
    DEPTNO : 10
    DNAME : ACCOUNTING
    LOC : NEW YORK
    PL/SQL procedure successfully completed.
    SQL>

  • Run time Column Name in the Select Statement

    Hi there,
    I face problem while writing sql statment for report in the Oracle reports.
    The prom is I want to bound the where clause column name with the value stored in a variable e.g.
    Select * from emp
    where Column_Name = 'XYZ' ;
    where the variable Column_Name have different values at different times, e.g.
    At a time the value of Column_Name is Dept then
    Select * from emp
    where Dept = 'XYZ' ;
    At other time value of Column_Name is City then
    Select * from emp
    where City = 'XYZ' ;
    Waiting for the response .
    Regards,
    Hafeez

    Hi,
    U can use lexical parameters for the solutions.U must be aware of it, but still i describe how to work it out.
    1)In your datamodel in object navigator create a parameter under User parameter node.Name the parameter, for eg. p_clause.
    set data type of parameter to character.
    2)write a select query eg.
    select * from emp &p_clause; --(THIS IS THE PARAMETER WE CREATED ABOVE)
    3)Now run your report
    Now in your parameter form pass the value for p_clause parameter.
    eg: where name='JACK';
    or
    where city='NEWYORK';
    or where deptno=10;
    But do it in steps as above mentioned.
    Do tell me if it works or not via mail on [email protected]
    Enjoy.......
    navneet jain
    [email protected]

  • What is the column name when use select ... from table(my_table)

    I have some code that takes a csv and loads it into a type table. I am now trying to select from this table but am not sure what column name to use in my cursor. (See below I have c2.???).
    FUNCTION in_list_varchar2 (p_in_list IN VARCHAR2) RETURN VARCHAR2_TT is
    l_tab VARCHAR2_TT := VARCHAR2_TT();
    l_text VARCHAR2(32767) := p_in_list || ',';
    l_idx NUMBER;
    BEGIN
    LOOP l_idx := INSTR(l_text, ',');
    EXIT WHEN NVL(l_idx, 0) = 0;
    l_tab.extend;
    l_tab(l_tab.last) := TRIM(SUBSTR(l_text, 1, l_idx - 1));
    l_text := SUBSTR(l_text, l_idx + 1);
    END LOOP;
    RETURN l_tab;
    END in_list_varchar2;
    schema_list := 'SCOTT, TOM, MIKE';
    schema_names := regexp_replace(schema_list, '([^,]+)', '''\1''');
    schema_list_t := DATAPUMP_UTIL.in_list_varchar2(schema_list);
    for c2 in
    select *from table(schema_list_t)   
    loop
    dml_str := 'DROP USER ' || c2.??? || 'CASADE';
    EXECUTE IMMEDIATE dml_str;
    end loop;

    Chris wrote:
    I have some code that takes a csv and loads it into a type table. I am now trying to select from this table but am not sure what column name to use in my cursor. (See below I have c2.???).
    FUNCTION in_list_varchar2 (p_in_list IN VARCHAR2) RETURN VARCHAR2_TT is
    l_tab VARCHAR2_TT := VARCHAR2_TT();
    l_text VARCHAR2(32767) := p_in_list || ',';
    l_idx NUMBER;
    BEGIN
    LOOP l_idx := INSTR(l_text, ',');
    EXIT WHEN NVL(l_idx, 0) = 0;
    l_tab.extend;
    l_tab(l_tab.last) := TRIM(SUBSTR(l_text, 1, l_idx - 1));
    l_text := SUBSTR(l_text, l_idx + 1);
    END LOOP;
    RETURN l_tab;
    END in_list_varchar2;
    schema_list := 'SCOTT, TOM, MIKE';
    schema_names := regexp_replace(schema_list, '([^,]+)', '''\1''');
    schema_list_t := DATAPUMP_UTIL.in_list_varchar2(schema_list);
    for c2 in
    select *from table(schema_list_t)   
    loop
    dml_str := 'DROP USER ' || c2.??? || 'CASADE';
    EXECUTE IMMEDIATE dml_str;
    end loop;
    I have some code that takes a csv and loads it into a type table.Why a type table? Where is type table defined as such?
    with PL/SQL, objects must be declared before they can be referenced.
    You need to correct syntax errors before tackling any runtime/logic flaws.

  • CASE in an order by clause?

    Can I use a case statement in an order by clause to acheive the following?
    I have set up a parameter (:p_order) and placed it in a case statement in my order by clause. The idea is that the user will select a value from a LoV in the report and then dependant upon which one they picked, it will order by their selection. The problem I'm hitting is that the CASE statement seems to want to return an actual value instead of just returning the alias name to complete the order by clause. Here is the syntax I'm using:
    ORDER BY
    CASE WHEN :p_order = 'INVOICE NUMBER' THEN INVOICE_NUMBER
    WHEN :p_order = 'INVOICE DATE' THEN INVOICE_DATE
         WHEN :p_order = 'VENDOR' THEN VENDOR_NAME
    WHEN :p_order = 'CHECK NUMBER' THEN CHECK_NUMBER
    WHEN :p_order = 'CHECK DATE' THEN CHECK_DATE
    WHEN :p_order = 'CHECK AMOUNT' THEN CHECK_AMOUNT
    WHEN :p_order = 'DOA CHECK NUMBER' THEN DOA_CHECK_NUMBER
    WHEN :p_order = 'DOA CHECK DATE' THEN DOA_CHECK_DATE
    WHEN :p_order = 'DOA CHECK AMOUNT' THEN DOA_CHECK_AMOUNT
    END
    Any ideas? How can I force the case statement to return the alias name instead of a value or is that defiance in the face of what case is? Thanks!
    Steve

    Note, however, that if you want to dynamically choose the ORDER, you have to use dynamic SQL, not static SQL.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Invalid Column Name on db link from 11.2.0.2 Oracle to 11.2.0.2 Gateway

    Hello, I am running the Oracle database 11.2.0.2 and using a database link accessing a sql server 2008 R1. The link is working fine, but a table has columns that are greater than 30 chars and Oracle db gateway cannot access this. Does anyone know of a fix or workaround?
    Thanks
    Jennifer L.

    As this is an Oracle database limitation you have to shrink the column name by for example creating a view on the SQL Server side defining aliases for each larger column name and then select from the view rather then from the table directly.
    See also MOS (=My Oracle Support) note: Replication From Sql Server To Oracle Database Failes With "Ora-00972: Identifier Is Too Long" (Doc ID 1322826.1)

  • Getting column names from cursor

    Hi all
    I have procedure which produces list of applied for jobs web page(using htp. package)
    I got result in cursor, but have to provide dinamic sort, based on colimn pressed
    procedure my_application_list
    (pi_resume_num     in varchar2 default null
    ,pi_sort_col     in varchar2 default null
    ,pi_page_no     in varchar2 default null
    ,pi_action     in varchar2 default null
    ,pi_msg          in varchar2 default null
    is
    CURSOR cur_job IS
         SELECT      jtl.JOB_TITLE
              ,jtl.COMPANY_NAME
              ,a.APPLY_DATE
              ,a.lang
              ,a.job_id
         FROM job_tl jtl, applied_for_job a, gateway gt
         WHERE a.job_seeker_id=app.job_Seeker
         AND a.job_id=jtl.job_id
         AND a.lang=jtl.lang
         AND a.gateway=gt.gateway
         AND jtl.lang=(SELECT substr(MIN(lt.order_list||jtl0.lang),2) lang
                   FROM      job_tl jtl0
                        ,language_tl lt
                   WHERE jtl0.job_id = a.job_id
                   AND jtl0.lang=lt.lang
                   AND lt.gui_lang=app.language)
         ORDER BY pi_sort_col
    rest of code
    The columns displayed in web page are Job_title, Company_name and Applied_date
    This page is displyed well, bu without column nmes at the top. I am trying to get column names from cursor in order to have ORDER BY <pi_sort_col>
    can someone help how i can get those column names:Job_title, Company_name and Applied_date
    User will be able to click on column and sort
    Thank in advance .I appreciate any help

    Hi Francisco
    Here is my code
    CREATE OR REPLACE PACKAGE BODY cc_web_application_list
    IS
    TYPE COL_NAME_LIST IS TABLE OF VARCHAR2(100)
         INDEX BY BINARY_INTEGER;
    TYPE COL_ORDER_LIST IS TABLE OF VARCHAR2(30)
         INDEX BY BINARY_INTEGER;
    col_name_t col_name_list;
    col_order_t col_order_list;
    procedure my_application_list
         (pi_resume_num     in varchar2 default null
         ,pi_sort_col     in varchar2 default null
         ,pi_page_no     in varchar2 default null
         ,pi_action     in varchar2 default null
         ,pi_msg          in varchar2 default null
    is
    l_my_page_no      PLS_INTEGER :=     TO_NUMBER(nvl(pi_page_no,1));
    l_js_name          gam_user.username%TYPE;
    l_js_first_name          gam_user.first_name%TYPE;
    l_cnt                PLS_INTEGER := 0;
    l_scr_lines      PLS_INTEGER := 0;
    l_curline           PLS_INTEGER;
    l_jobs_applied           PLS_INTEGER;
    l_total_rec      PLS_INTEGER;
    l_total_pages      PLS_INTEGER;
    l_pos               PLS_INTEGER;
    l_first               PLS_INTEGER :=0;
    last                PLS_INTEGER :=0;
    l_lines           PLS_INTEGER := 10;
    col_name      VARCHAR2(100) := col_name_t(3) ;
    col_order           VARCHAR2(30) := 'DESC';
    str                VARCHAR2(2000);
    TYPE display_rec IS TABLE OF VARCHAR2(500) INDEX BY BINARY_INTEGER;
    display           display_rec;
    TYPE page_table_type IS TABLE OF PLS_INTEGER INDEX BY BINARY_INTEGER;
    page_number          page_table_type;
    CURSOR cur_job IS
         SELECT      jtl.JOB_TITLE job_title
              ,jtl.COMPANY_NAME company_name
              ,a.APPLY_DATE apply_date
              ,a.lang
              ,a.job_id
         FROM job_tl jtl, applied_for_job a, gateway gt
         WHERE a.job_seeker_id=app.job_Seeker
         AND a.job_id=jtl.job_id
         AND a.lang=jtl.lang
         AND a.gateway=gt.gateway
         ORDER BY a.apply_date;
    This decode is a problem
              decode(col_order,'ASC'
                   ,decode(col_name
                   ,col_name_t(1), jtl.job_title
                   ,col_name_t(2), jtl.company_name
                   ,col_name_t(3), TO_CHAR(a.apply_date, 'YYYYMMDDhh24miss')
                   ,a.apply_date)
                   ) ASC
              ,decode(col_order,'DESC'
                   ,decode(col_name
                   ,col_name_t(1), jtl.job_title
                   ,col_name_t(2), jtl.company_name
                   ,col_name_t(3), TO_CHAR(a.apply_date, 'YYYYMMDDhh24miss')
                   ,a.apply_date)
                   ) DESC
              ,a.apply_date
    TYPE rec_one IS TABLE OF cur_job%ROWTYPE INDEX BY BINARY_INTEGER;
    r               rec_one;
    BEGIN
    BEGIN
    SELECT username,first_name
    INTO l_js_name,l_js_first_name
    FROM gam_user
    WHERE user_id = App.job_seeker;
    EXCEPTION
    WHEN OTHERS THEN NULL;
    END;
    Cc_Pkg_Elements.p_page_top_job_seeker(
    'Personal Job List'
    ,REPLACE(Txt_Proc_My_Joblist.title_job_list
         ,'##first_name##',l_js_first_name),'N' ,TRUE ,'Pxx');
    ----- get numer of records returned by query
    SELECT COUNT(1)
    INTO l_total_rec
    FROM     job_tl jtl,applied_for_job a
         ,gateway gt
    WHERE a.job_id = jtl.job_id
    AND     a.job_seeker_id     = App.job_seeker
    AND     a.gateway     = gt.gateway ;
    ------get number of pages
    l_total_pages:=CEIL (l_total_rec/l_lines);
    l_jobs_applied := 0;
    col_name := pi_sort_col;
    col_order := pi_sort_col;
    --get first positions
    l_first := (nvl(l_my_page_no,1) - 1) * l_lines + 1;
    FOR rec IN cur_job LOOP
         l_cnt := l_cnt + 1;
         EXIT WHEN l_cnt > l_first + l_lines - 1;
         IF l_cnt >= l_first THEN
              l_scr_lines := l_scr_lines + 1;      
              r(l_scr_lines) := rec;          --assign counter from loop to r index
              IF rec.apply_date IS NOT NULL THEN
              l_jobs_applied := l_jobs_applied + 1;
              END IF;
         END IF;
    END LOOP;
    htp.p('<FORM ACTION="'||App.gateway||'8.my_application_list" METHOD="post">');
    htp.p('<table align="center">');
    htp.p('<tr><td>');
    IF r.COUNT = 0 THEN
         Web_Pkg_Elements.doc_msg(Txt_Proc_My_Joblist.no_jobs);
    END IF;
    htp.p('</td></tr>');
    htp.p('</table>');
    --table_heading(col_name ,col_order );
    htp.p('<table align=center>');
    htp.p('<tr align="center"><td>');
    FOR i IN 1..l_total_pages LOOP
         page_number(i) := i;
         IF page_number(i) = l_total_pages THEN
              htp.p('');
    ||'');
              Web_Pkg_Elements.doc_val_small(page_number(i)||'</A>');          
         ELSE
         htp.p('');
    |'||'');
         Web_Pkg_Elements.doc_val_small(page_number(i)||' |'||'</A>');     
         END IF;
    END LOOP;
    htp.p('</td></tr>');
    htp.p('</table>');
    htp.p('<table align=center>');
    FOR l_curline IN 1..l_scr_lines LOOP
         display(1) := NVL(r(l_curline).job_title, '<br>');
         display(2) := NVL(r(l_curline).company_name, '<br>');
         display(3) := NVL(Cc_Pkg_Nls.date2char(r(l_curline).apply_date, App.date_format), '<br>');
         IF MOD(l_curline, 2) = 0 THEN     
              Cc_Pkg_Elements.tr_even;
         ELSE
              Cc_Pkg_Elements.tr_odd;
         END IF;
         htp.p('<td>');
         htp.p('');
         Web_Pkg_Elements.doc_val(display(1)||'');
         htp.p('</td>');
         htp.p('<td>');
         Web_Pkg_Elements.doc_val(display(2));
         htp.p('</td>');
         htp.p('     <td>');
         Web_Pkg_Elements.doc_val(display(3));
         htp.p('     </td>');
    htp.p('</tr>');
    END LOOP;
    htp.p('</TABLE>');
    htp.p('<TABLE width="88%" BORDER="0" CELLPADDING="0" CELLSPACING="0"
                   align="center">');
    htp.p('<tr valign=bottom>');
    htp.p('<TD colspan=2 align=right>');
    IF l_my_page_no > 1 THEN
         htp.p('<P>'||'<IMG SRC="'||App.image||'prev.gif" ALT="'
         ||Txt_Proc_My_Joblist.prev
         ||'"'     ||' HEIGHT=20 BORDER=0 ALIGN=bottom '
         ||'hspace=2>');
    END IF;
    IF l_my_page_no < CEIL (l_total_rec/l_lines) THEN
         htp.p(' <a href="'||
         web_pkg_elements.link$$(App.gateway||'8.my_application_list?'
         ||'pi_sort_col='||Web_Pkg_Elements.replace_in_url(pi_sort_col)
         ||'&pi_msg=&pi_page_no='||TO_CHAR(l_my_page_no + 1)
         ||">'||'<IMG SRC="'||App.image||'next.gif" ALT="'
         ||Txt_Proc_My_Joblist.NEXT
         ||'"' ||' HEIGHT=20 BORDER=0 ALIGN=bottom '
         ||'hspace=2></a>');
    END IF;
    htp.p('</TD>');
    htp.p('</TR>');
    htp.p('     </TABLE>');
    htp.formHidden('pi_sort_col', pi_sort_col);
    htp.formHidden('pi_page_no', pi_page_no);
    htp.p('</FORM>');
    END my_application_list;
    END ; --cc_pkg_application_list

  • Renaming Column Names in a single shot in Requests

    Hi All,
    We are having one issue while trying to rename the column in the requests.
    Requirement:
    We are having two presentation table "Fact Summary" and "Countries Dimension". Both of these tables contain one column "Country Description".
    Presently in all the reports we have developed till now, we used "Fact Summary"."Country Description".
    Now the users want us to replace "Fact Summary"."Country Description" with "Countries Dimension"."Country Description" and delete the "Country Description" from "Fact Summary" table.
    Approach we followed:
    Opened the Catalog Manager in Offline mode and used the XML Search and Replace option.
    With this option we are able to replace column names that are selected in a request but not those just used as filters(is prompted).
    Example:
    Suppose we have one request with "States Dimension"."State" seleted and "Fact Summary"."Country Description" as filter, we are able to not able to replace "Fact Summary"."Country Description" with "Countries Dimension"."Country Description"
    Can anyone please help me...Is there any alternative solution for this?
    Thanks in Advance.....

    Nope, I don't have a solution for this. You must never model descriptive columns in a fact table. Even when you have descriptive columns or textual content in one of your fact table columns, you should model them as part of a logical dimension table. Let this be a good lesson.
    Regards,
    Stijn

  • Track down an INVALID COLUMN NAME.

    Hi,
    I have a SQL statement which contains a lot of column names and joins.
    There may be approx 150 column names in my Select clause.
    Now,when I run this in the User Env,i get the correct output.
    But when this is run in the Prod Env,I get the Error:
    ERROR at line 1:
    ORA-29532: Java call terminated by uncaught Java exception:
    oracle.jdbc.driver.OracleSQLException: ORA-00904: invalid column nameIs there any way where I can find out which is the INVALID COLUMN NAME in my SQL statement which gives an error when run in PROD env?

    Oracle9i or later would tell you the exact name of the column that is the problem. MAybe, you are on a release earlier than that.
    SQL> desc emp
    Name                                      Null?    Type
    EMPNO                                     NOT NULL NUMBER(4)
    ENAME                                              VARCHAR2(10)
    JOB                                                VARCHAR2(9)
    MGR                                                NUMBER(4)
    HIREDATE                                           DATE
    SAL                                                NUMBER(7,2)
    COMM                                               NUMBER(7,2)
    DEPTNO                                             NUMBER(2)
    TITLE                                              VARCHAR2(20)
    SQL> select ename, invalid_column from emp ;
    select ename, invalid_column from emp
    ERROR at line 1:
    ORA-00904: "INVALID_COLUMN": invalid identifier
    SQL> disconnect
    Disconnected from Oracle9i Enterprise Edition Release 9.2.0.3.0 - Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.3.0 - Production
    SQL>What you could do is get the query that you are executing and run it in production SQL*Plus (or ask your DBA to do that for you). SQL*Plus would tell you the line number that has the problem (and hence you would know the column name):
    SQL> select ename,
      2  empno,
      3  job,
      4  invalid_column,
      5  sal
      6  from emp ;
    invalid_column,
    ERROR at line 4:
    ORA-00904: "INVALID_COLUMN": invalid identifier
    SQL>See, SQL*Plus tells you the problem is at line 4 and line 4 contains the offending column name.

  • TO Rename a column name

    Hi all,
    I have a table employee with columns
    'employee_id',
    'employee_name'
    ' employee_city' ( Note the spaces before the column name )
    The table is created successfully.
    But i cant to able to retreive the data by specifying the column name..
    eg: select employee_city from employee.
    It throws an error.
    Please send me a solution to reanme the column name, so that it should not contain any spaces at start & end.
    Thanks & Regards,
    Hariharan ST

    Obviously the table was created this way:
    SQL>create table testtab
    "employee_id" number,
    "employee_name" varchar2(100),
    " employee_city" varchar2(100)
    Table created.
    SQL>desc testtab
    Name                                      Null?    Type
    employee_id                                        NUMBER
    employee_name                                      VARCHAR2(100)
      employee_city                                     VARCHAR2(100)Note the double quotes: Columns that are created this way can only be selected using double quotes, too:
    SQL>select employee_city from testtab;
    select employee_city from testtab
    ERROR at line 1:
    ORA-00904: "EMPLOYEE_CITY": invalid identifier
    SQL>select " employee_city" from testtab;
    employee_city
    Chicago
    SQL>This of course is a very bad idea. Dave already showed you how to rename the columns.
    Regards,
    Gerd

  • Is it possible to return column names?

    Hi!
    Is it possible to return column names of a select statement?
    Let's say I have table with the following columns:
    Col1
    COl2
    Col3
    And I have a select statement like this:
    Select * from XX
    Is it then possible either through SQL or PL/SQL to return the column names?
    Br
    Casper Thrane

    If you are looking at column names for a particular table,
    then you can query aganist the sys.User_Tab_Columns.
    here is the piece of code.
    SELECT Column_Name
    FROM Sys.User_Tab_Columns
    WHERE Table_Name = 'TABLENAME';
    Remember TABLENAME is the name of the table in CAPITAL letters.
    You can use this in SQL or PL/SQL code.
    You can also use the ALL_Tab_Columns but then you have add
    another AND condition, because, the there may be a same table name for different users. so one has to use the owner Column in your query.
    SELECT Column_Name
    FROM All_Tab_Columns
    WHERE Table_NAME = 'TABLENAME'
    AND OWNER = 'TABLE_DESIRED_OWNER';

  • Order query depending on column names passed at runtime

    Hi
    Can any one suggest how to order by at run time depending on column name passed as parameter.
    create or replace procedure dummy_proc( p_orderby varchar2,p_refcursor out sys_refcursor)
    is
    begin
         open p_refcursor for select * from
         emp where Status='A'
              order by (select p_orderby from dual);
    end;
    --execution part for testing
    declare
         v_outcursor sys_refcursor;
         v_rec_data emp%rowtype;
         v_cnt number;
    begin
         dummy_proc ('ename,sal',v_outcursor);
         begin
              loop
                   fetch v_outcursor into v_rec_data;
                   v_cnt:=v_outcursor%rowcount;
                   exit when v_outcursor%notfound;
                   dbms_output.put_line('empno '|| to_char(v_rec_data.empno));
                   dbms_output.put_line('empno '|| v_rec_data.ename);
              end loop;
         end;
         dbms_output.put_line('Count is'|| to_char(v_cnt));
    end;
    we do not want to something like below as my actual query is very big with union statements and case expressions, (below is just an similar example)
    how i tried to order by but its not working.
    v_sql='select * from emp where empno= '|| p_empno || ' order by '|| p_orderby;
    open p_refcursor for v_sql;
    Thanks in advance
    Vishal

    we do not want to something like below as my actual
    query is very big with union statements and case
    expressions, (below is just an similar example)
    how i tried to order by but its not working.
    v_sql='select * from emp where empno= '|| p_empno ||
    ' order by '|| p_orderby;
    open p_refcursor for v_sql;I agree, you really don't want to do that, you want to use BIND VARIABLES.
    v_sql := ' select * from emp where empno = :bound_empno order by :bound_orderby';
    open p_refcursor for v_sql using p_empno, p_orderby;
    [pre]
    The size of the statement shouldn't come in to play, if the only dynamic portion of it is the order by clause then declare a constant which is the large query (you can use a LONG datatype) and then concatenate in the order by clause before you return the reference cursor.
    Unless you can give a legitimate reason for why you cannot use Dynamic SQL (not why you do not want to use it) this would be my approach.
    And please, if you don't know what a bind variable is...read about them, or your system will suffer.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Execute SQL Task fails when specific column names are mentioned in Excel Query

    Hi,
    I have a requirement for extracting Excel data with thespecific column order. So instead of using the below query,
    Select * From [Sheet1$A1:ZZ1]
    I use the below one,
    Select col1,
    col2,
    col91
    From [CRM$A1:ZZ1]
    So I have totally 91 columns.
    I don't face any issues when i use the before query. i.e. direct select * from sheet1
    But when i specify column names and do a select from the sheet it throws error as below,
    [Execute SQL Task] Error: Executing the query "Select
    [Col1] 
    From [Sheet1$..." failed with the following error: "No value given for one or more required parameters.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not
    set correctly, or connection not established correctly.
    I just need to retrieve the column name alone and not any of the values to it. So when i do simple select * it gives the column names in the order of what it is been with the excel. But i do want it to be sorted in alphabetically and to retrieve the column
    names. 
    I am not getting any proper solution for this for past 1 and a half days. May anyone of you please help me get it sorted? - Thank you!
    --------------------------- Radhai Krish | Golden Age is no more far | --------------------------

    Please use something like below:
    SELECT F1 AS Col1, F2 AS Col2, F3 AS Col3, ...
    FROM [Sheet1$A1:ZZ1]
    Cheers,
    Vaibhav Chaudhari
    [MCTS],
    [MCP]

  • Problems on selecting views with french characters into column names

    Hi All,
    I have views with column names such as "Détermination Planimétriq" or "Année de construction:*";
    I can get in my c# function this columns names from ALL_VIEWS dictionary table, but if I try to make a selectionby use of an OracleCommand, Oracle returns an "Invalid identifier" error:
    SELECT "Détermination Planimétriq" FROM mytable;
    System.Data.OracleClient.OracleException (0x80131938): ORA-00904: "Determination Planimetriq": invalid identifier at System.Data.OracleClient.OracleConnection.CheckError(OciErrorHandle errorHandle, Int32 rc) at ...
    Any suggestion?...

    Be wary of using character codes outside the Western European "simple" alphanumeric [A-Z0-9] for object names, i.e. columns, table names, function and procedure names, and so on.
    First reason, there is a 30 character limit for most object names, and characters that have to be spelled out with unicode characters take more space, i.e.:
    select dump( 'Détermination Planimétriq'  ) from dual;
    DUMP('D?TERMINATIONPLANIM?TRIQ')
    Typ=96 Len=29: 68,239,[ ... ]Although the varchar string for that column name looks like 25 characters, it needs room for 29 to store the e<acute> character. And could also depend on the client settings. Using case sensitive names is not a best practice, its better to avoid specifying objects with the double quotes.
    http://docs.oracle.com/cd/E11882_01/server.112/e26088/sql_elements008.htm#i27570

Maybe you are looking for