Select query output as a separate column

Hi,
How to represent the different values in the same table column as an output in the separate columns using the select query ?
For example,
Table "A" has column "col1"
col1 contains values as below:
col1
====
1
2
3
4
5
now want to display the above column values as a separate column as the output.
col_alias1 col_alias2 col_alias3 col_alias4 col_alias5
1 2 3 4 5
How it can be done ?
Regards
Edited by: user640001 on Jan 31, 2011 11:19 PM

Hi,
You can try something mentioned in this link.
http://www.oracle-base.com/articles/misc/StringAggregationTechniques.php
or try this
with t as (
select 'PID12' as product_id,  1 as status_id, 'Time1' as time from dual union all
select 'PID13', 2, 'Time2' as time from dual union all
select 'PID14', 3, 'Time3' as time from dual)
select min(case when status_id = 1 then product_id || ' ' || time end) as Recieved, min(case when status_id = 2 then product_id || ' ' || time end) as Accepted,
       min(case when status_id = 3 then product_id || ' ' || time end) as Delivered from tcheers
VT
Edited by: VT on Feb 1, 2011 5:28 PM

Similar Messages

  • How to store select query output in arrays.

    i created a varray type variables and now want to assign some data though select query output in pl/sql code as well as in reports 6i.

    You're in the wrong forum (this one is for issues with the SQL Developer tool). You were in the right one where you posted first, but don't reuse unrelated threads as you did.
    Regards,
    K.

  • Select query output needed

    Hi
    SELECT CUREPRESS,PRODUCTIONCODE,YYYYMMDD STARTDATE,
    CASE
    WHEN SCHEDULE1 = 0 AND SCHEDULE2 = 0 AND SCHEDULE3 >0 AND ROUND(30-SCHEDULE3/CURECAPACITY*24,0)>24 THEN
              ROUND(30-(SCHEDULE3/CURECAPACITY*24),0)-24
    WHEN SCHEDULE1 = 0 AND SCHEDULE2 = 0 AND SCHEDULE3 >0 AND ROUND(30-SCHEDULE3/CURECAPACITY*24,0)<=24 THEN
              ROUND(30-SCHEDULE3/CURECAPACITY*24,0)
    WHEN SCHEDULE1 = 0 AND SCHEDULE2 >0 AND SCHEDULE3 >0 THEN
    ROUND(22-SCHEDULE2/CURECAPACITY*24,0)
    WHEN SCHEDULE1 > 0 AND SCHEDULE2 >0 AND SCHEDULE3 >0 THEN
    ROUND(14-SCHEDULE1/CURECAPACITY*24,0)
    END STARTDATE1
    FROM (
    SELECT curepress,PRODUCTIONCODE,YYYYMMDD,schedule1,schedule2,schedule3,curecapacity
    FROM ORGCURESCHEDULEDAY A
    WHERE YYYYMMDD = (SELECT MIN(YYYYMMDD)
    FROM ORGCURESCHEDULEDAY B
    WHERE A.PRODUCTIONCODE=B.PRODUCTIONCODE
    AND A.CUREPRESS =B.CUREPRESS )
    )GROUP BY PRODUCTIONCODE,CUREPRESS,YYYYMMDD,SCHEDULE1,SCHEDULE2,SCHEDULE3,CURECAPACITY
    ORDER BY CUREPRESS,PRODUCTIONCODE
    The above query gives 4 column values like..!!
    curepress productioncode startdate startdate1
    0101      IO72A     20110412     22 -------> case statement gives this value as startdate1
    0101      OQ36A     20110221     6
    I want to display the output like startdate1 as (startdate + statedate1)
    curepress productioncode startdate startdate1
    0101      IO72A     20110412     20110412 22.00
    0101      OQ36A     20110221     20110221 06.00
    please help me ...!!
    regards
    Karanam

    Please don't duplicate your questions.
    select query giving error
    Locking this thread.

  • CohQL command line Tool select query output in file (unix)

    Ho to insert Coherence CohQL command line Tool select query result in file in unix platform. I have tried below query but failed
    query.cmd -s -c -l "select * from 'dist-example'" >myOutput.txt
    I also tried below query, result is displayed in command line but no file is created in folder.
    select * from dist-example >myOutput.txt
    I also tried one more query, result is displayed in command line but no file is created in folder.
    select * from dist-example >/opt/bin/myOutput.txt

    Hi,
    In Unix you should use query.sh instead of query.cmd
    In your case then the command would be smething like:
    query.sh -s -c -l "select * from 'dist-example'" >myOutput.txt
    You can also try using '>>' instead of '>' in order to redirect to a text file.
    Hope this helps.
    -Cris

  • Select query with combination of two columns

    I need looking to write a nested select statement that would achieve the following.
    Support i have a table as follows
    TestTable
    Name : Age : Country
    Test1 : 10 : USA
    Test2 : 11 : USA
    Test3 : 12 : USA
    Test4 : 11 : Canada
    Test5 : 12 : Canada
    Now i want to select from the above table the following information.
    Get all the names of people who dont belong to this combinations (10:USA,11:Canada,12:Canada). The list can be huge.
    The result should be
    Test1:10:USA
    Test1:12:USA
    If it were one combination i can write
    select * from TestTable
    where age <> 10 and country <>Canada
    Also i can also do
    select * from TestTable
    where age NOT IN (10,11) and country NOT IN (USA,COUNTRY)
    But i don't this it would give me correct result.

    sush_msn wrote:
    Is there a way i can pass the age and country as list to the query ?You asked the right question.
    Three things you need to know:
    1) Your test data doesn't cover all combinations. Here is more complete test data:create table test_table1 as
    WITH AGES AS (
      SELECT LEVEL+10 AGE FROM DUAL CONNECT BY LEVEL <= 3
    ), COUNTRIES AS (
      SELECT 'USA' COUNTRY FROM DUAL
      UNION ALL
      SELECT 'CANADA' COUNTRY FROM DUAL
    SELECT 'Test' || ROWNUM NAME, AGE, COUNTRY FROM AGES, COUNTRIES;
    NAME                                                AGE COUNTRY
    Test1                                                11 USA    
    Test2                                                11 CANADA 
    Test3                                                12 USA    
    Test4                                                12 CANADA 
    Test5                                                13 USA    
    Test6                                                13 CANADA2) Now here is the answer to your question. You can put two or more values together in an expression by putting parentheses around them.SELECT * FROM TEST_TABLE1
    WHERE (AGE, COUNTRY) NOT IN (
      (11, 'USA'),
      (12, 'CANADA')
    NAME                                                AGE COUNTRY
    Test2                                                11 CANADA 
    Test3                                                12 USA    
    Test5                                                13 USA    
    Test6                                                13 CANADAThis is what Etbin did above, but he used a SELECT instead of a list of values.
    3) Can AGE or COUNTRY ever be NULL? Do you want to return the records that have NULL values in them? If so, you need to use NOT EXISTS instead of NOT IN. Warning: Etbin's code needs a little change: "where (age,country) = (t.age,t.country)" should be "where (age,country) = ((t.age,t.country))". You always need extra parentheses on the right side.

  • Spool SELECT query output in unix

    Dear All,
    I have a requirement to spool out the data from a table into a log file and send it as an email.
    In my unix shell script, this is what I am doing:
    set def off;
    set echo off
    spool mail_text.log
    begin
    SELECT *  FROM table1;
    end;
    spool off;
    /usr/lib/sendmail -v <mail_id> < mail_text.logOn running the shell script, I get an error -
    SELECT * FROM table1;
    ERROR at line 2:
    ORA-06550: line 2, column 1:
    PLS-00428: an INTO clause is expected in this SELECT statement
    if I am to use INTO clause, how would I spool out the data?
    Looking forward to your suggestions.

    Caitanya wrote:
    Dear All,
    I have a requirement to spool out the data from a table into a log file and send it as an email.
    In my unix shell script, this is what I am doing:
    set def off;
    set echo off
    spool mail_text.log
    begin
    SELECT *  FROM table1;
    end;
    spool off;
    /usr/lib/sendmail -v <mail_id> < mail_text.logOn running the shell script, I get an error -
    SELECT * FROM table1;
    ERROR at line 2:
    ORA-06550: line 2, column 1:
    PLS-00428: an INTO clause is expected in this SELECT statementWhen you are issuing a select statement in PL/SQL (if you use the sql inside Begin and end), you need to put "into" some variable.
    Try this
    set def off;
    set echo off
    spool mail_text.log
    SELECT *  FROM table1;
    spool off;
    /usr/lib/sendmail -v <mail_id> < mail_text.log-Arun

  • Simple select query output-

    Hi Guys,
         I have the following select statement…
    SELECT *
    FROM (SELECT '111', '222', '333' FROM dual)
    Output
         ‘111’     ‘222’     ‘333’
    1     111     222     333
    But the output I was looking for was,
         my_col
    1 111
    2 222
    3 333
    Can someone let me know how to achieve this?
    Many Thanks…
    Napster

    SELECT rownum,
      column_value
       FROM
      (SELECT '111' col1, '222' col2, '333' col3 FROM dual
      ) t,
      TABLE(sys.odcivarchar2list(t.col1,t.col2,t.col3))Ravi Kumar

  • Select query giving error

    Hi can Some one help me how to fit the query in the Main query, I need to selete SYS_ID the below Work around query is getting the output correctly
    but when i tried to put in the main query am getting ORA-00933 not sure how to fix this. Can some one advice me where am making wrong.
    Work Around query :
       SELECT ALTID.B_SYS_ID FROM N08.B_ALT_ID_TB ALTID WHERE ALTID.B_ALT_ID
               IN ( SELECT MEDCO.RE_MEDCD_ID_NUM 
                 FROM N09.T_MEDCD_ID MEDCO
              INNER JOIN N09.T_POLY POLY
                    ON POLY.RE_UNIQUE_ID = MEDCO.RE_UNIQUE_ID) AS B_SYS_ID
    Need to integerate the above column in the below query.
    Main Query :
    SELECT 'Diff' AS SC,
         POLY.ID,
          ALTID.B_SYS_ID FROM N08.B_ALT_ID_TB ALTID WHERE ALTID.B_ALT_ID
               IN ( SELECT MEDCO.RE_MEDCD_ID_NUM 
                 FROM N09.T_MEDCD_ID MEDCO
              INNER JOIN N09.T_POLY POLY
                    ON POLY.RE_UNIQUE_ID = MEDCO.RE_UNIQUE_ID) AS B_SYS_ID,
        NULL AS BEG_DT,
      NULL AS ID,
    FROM
       N09.T_POLY POLY
    Oracle Version : 10gR2
    Thanks in advance.

    Hi,
    Hillbird wrote:
    Hi Frank,
    Thanks for your responces. The Error am getting is at line number 7 & col# 55 -- ON POLY.RE_UNIQUE_ID = MEDCO.RE_UNIQUE_ID) AS B_SYS_ID,.
    I also changed the alias name in thesubquery as S-poly and left the main query alias as POLY. You still haven't posted a completed query, or any sample data and results.
    But still i am getting the same error message.
    Error Message
    ORA-00933 : Sql command not properly ended
    oo933 00000 - "Sql command not properly ended"
    Vendor Code 933 Error at line 7 column 55
    Iam framing a select query, The work around query is used to checkhow to reterive the value from the DB and with the business rules. on which the framing
    select query the B_sys_id comes in column 3 and i still have more columns to select. Hence i even tried as below
    SELECT 'Diff' AS SC,
    POLY.ID,
    ALTID.B_SYS_ID FROM N08.B_ALT_ID_TB ALTID WHERE ALTID.B_ALT_ID
    IN ( SELECT MEDCO.RE_MEDCD_ID_NUM 
                 FROM N09.T_MEDCD_ID MEDCO
                 WHERE POLY.RE_UNIQUE_ID = MEDCO.RE_UNIQUE_ID),
    NULL AS BEG_DT,
    NULL AS ID,
    FROM
    N09.T_POLY POLY
    But still the same error message i got.
    Hence i just tried as below
    SELECT 'Diff' AS SC,
    1 as dummy,
    2 as dummy_1,
    ALTID.B_SYS_ID FROM N08.B_ALT_ID_TB ALTID WHERE ALTID.B_ALT_ID
    IN ( SELECT MEDCO.RE_MEDCD_ID_NUM 
                 FROM N09.T_MEDCD_ID MEDCO
              INNER JOIN N09.T_POLY POLY
    ON POLY.RE_UNIQUE_ID = MEDCO.RE_UNIQUE_ID)
    This is working.
    Can you please let me know what is that i need to do if i want to add more columns in the select clause after
    this line ON POLY.REUNIQUE_ID = MEDCO.RE_UNIQUE_ID)_
    Thanks.
    A query (not counting sub-queries) has, at most, only one of each type of clause: one SELECT clause, followed by one FROM clause, followed (optionally) by one WHERE clause. All items to be returned go together in the one SELECT clause. All tables needed are named in the on FROM clause. All filtering conditions go together in the one WHERE clause.
    Perhaps you meant something like this:
    SELECT  'Diff'           AS SC
    ,          POLY.ID
    ,           ALTID.B_SYS_ID
    ,       NULL AS BEG_DT
    ,     NULL AS ID
    FROM     N08.B_ALT_ID_TB ALTID
    JOIN    N09.T_POLY     POLY   ON  altid.column_a  = poly.column_b
    WHERE      ALTID.B_ALT_ID     IN (
                          SELECT  MEDCO.RE_MEDCD_ID_NUM 
                             FROM    N09.T_MEDCD_ID           MEDCO
                             WHERE   POLY.RE_UNIQUE_ID      = MEDCO.RE_UNIQUE_ID
                      )With the little information I have, I can't even guess what the real join condition(s) might be. I used
    ON  altid.column_a  = poly.column_bjust to show the correct syntax.

  • Removing Leading zeros from query output.

    Hello Experts,
    Is it possible to remove leading zeros from the query output for a particular column?
    I have a characteristics 'Reference Document' which has values like '000001386'. The users just need '1386' to be displayed and have asked us to remove the leading zeros.
    Is there something that can be done for this at a query level? I can't modify the underlying InfoProvider because this requirement is just for one set of users, the other users need the document nmber in the original format.
    Thanks
    Arvind

    Hi,
    you can use ALPHA conversion option in the definition of that particular characteristic.
    Try this code  in a routine.,in query designer;
    data a(9) value '000001386'.
    SHIFT a LEFT DELETING LEADING '0'.
    write:/ a.
    Output will be : 1386
    Or use this method also
    data a(9) value '000001386'.
    Call function 'CONVERSION_EXIT_ALPHA_OUTPUT'
    Exporting
    input = a
    Importing
    output = a.
    write a.
    output:
    1386
    Regards
    CSM Reddy

  • To lock the output of a SELECT query

    Hi,
    I want to lock the output of a SELECT query to some transaction.
    I have wriiten it as follows , the output of the query is a single row;
    SELECT empname
    FROM employees
    where empid = 100
    FOR UPDATE;
    Specifying only FOR UPDATE is proper or do i need to specify some more clause ??
    Thanks.

    bscalzo wrote:
    You can also specify the columns to lock if you like:
    select x, y, z from aaa where x = 1 for update of x, y;
    But the locking is still currently only done at the row level - but who knows what the future might offer. May not hurt to have the columns named for thay day when the syntax and engine sync up :)It might be worth to amend that specifying the columns is already particularly relevant if you select from multiple tables/views in order to specify which rows of which table/view to lock.
    Regards,
    Randolf
    Oracle related stuff blog:
    http://oracle-randolf.blogspot.com/
    SQLTools++ for Oracle (Open source Oracle GUI for Windows):
    http://www.sqltools-plusplus.org:7676/
    http://sourceforge.net/projects/sqlt-pp/

  • Can I get a query to get the output data like 4th column instead of 3rd col

    Can I get a query to get the output data like 4th column instead of 3rd column ?
    SQL&gt; select emp.deptno, empno, rownum from emp, dept where emp.deptno=dept.deptno;
    DEPTNO EMPNO ROWNUM
    10 7782 *1* *1*
    10 7839 *2* *2*
    10 7934 *3* *3*
    20 7369 *4* *1*
    20 7876 *5* *2*
    20 7902 *6* *3*
    20 7788 *7* *4*
    20 7566 *8* *5*
    30 7499 *9* *1*
    30 7698 *10* *2*
    30 7654 *11* *3*
    30 7900 *12* *4*
    30 7844 *13* *5*
    30 7521 *14* *6*
    14 rows selected.

    SQL> select emp.deptno, emp.empno,
      2    row_number() over(order by emp.deptno, emp.empno) rn,
      3    row_number() over(partition by emp.deptno order by emp.empno) dept_rn
      4  from emp, dept
      5  where emp.deptno=dept.deptno
      6  order by emp.deptno, emp.empno;
        DEPTNO      EMPNO         RN    DEPT_RN
            10       7782          1          1
            10       7839          2          2
            10       7934          3          3
            20       7369          4          1
            20       7566          5          2
            20       7788          6          3
            20       7876          7          4
            20       7902          8          5
            30       7499          9          1
            30       7521         10          2
            30       7654         11          3
            30       7698         12          4
            30       7844         13          5
            30       7900         14          6
    14 rows selected.Regards,
    Dima

  • Appearing Duplicate column in  ABAP QUERY  output list.

    Hi ,
             I have created a report using SAP QUERY having issue on output display  showing duplicate columns  name Weight Unit (LIKP-GEWEI ) and rest          of  field area  coming fine .
                  Kindly help to solve the issue .
             Thanks .

    Hi,
    The currency and quantity units get automatically displayed based on the currency and quantity fields on the output list. However you can restrict it by selecting those fields and choose No currency fields before or after and apply.
    How to do?
    1. Goto SQ01, provide your query name and select "Infoset Query".
    2. Now choose the currency/quantity fields on the lower bottom of window.
    3. Right click on the field and traverse to Unit->Do not Output.
    Hope this helps!
    Br,
    Maju

  • Label styled output by select query

    Hi,
    How do i get output of select query of EMP table of scott schema as below :
    Using Oracle 10g on windows xp machine :
    1.  EMPNO:7499                    2.   EMPNO:7521                    3.   EMPNO:7566
        ALLEN                         WARD                         JONES     
        SALESMAN                         SALESMAN                         MANAGER     
        HIREDATE:20-FEB-81                    HIREDATE:22-FEB-81                    HIREDATE:02-APR-81     
        SAL:1600                         SAL:1250                         SAL:2975
    <<<<BLANK LINE 1>>>>  This is not part of output
    <<<<BLANK LINE 2>>>>
    <<<<BLANK LINE 3>>>>
    <<<<BLANK LINE 4>>>>                                                  
    4.  EMPNO:7654                    5.   EMPNO:7698                    6.   EMPNO:7782
        MARTIN                         BLAKE                         CLARK     
        SALESMAN                         MANAGER                         MANAGER     
        HIREDATE:28-FEB-81                    HIREDATE:01-MAY-81                    HIREDATE:09-JUN-81     
        SAL:1250                         SAL:2850                         SAL:3000
    <<<<BLANK LINE 1>>>>  This is not part of output
    <<<<BLANK LINE 2>>>>
    <<<<BLANK LINE 3>>>>
    <<<<BLANK LINE 4>>>>                                        Means, i wish to print the addresses of my address table; so here i am giving you EMP as example that how it will create create above output if :
    (A) suppose above it is in 3 columns; i wish to change in N number of columns?
    (B) above there are 4 blank lines, i wish to change in N number of blank lines?
    (C) above order by empno, i wish to change in any order by column as well.
    Thanking you,
    Regards
    Nisha Sharma

    WITH t AS (
               SELECT  e.*,
                       ROW_NUMBER() OVER(ORDER BY CASE :order_indicator
                                                    WHEN 1 THEN to_char(empno,'9999')
                                                    WHEN 2 THEN ename
                                                    WHEN 3 THEN job
                                                    WHEN 4 THEN to_char(hiredate,'yyyymmdd')
                                                  END
                                        ) rn
                 FROM  EMP e
    SELECT  REPLACE(SYS_CONNECT_BY_PATH(RPAD(TO_CHAR(rn,'999') || '.  EMPNO:' || empno,30),','),',') ||
            CHR(13) || CHR(10) || '       ' ||
            REPLACE(SYS_CONNECT_BY_PATH(RPAD(ename,30),','),',') ||
            CHR(13) || CHR(10) || '       ' ||
            REPLACE(SYS_CONNECT_BY_PATH(RPAD(job,30),','),',') ||
            CHR(13) || CHR(10) || '       ' ||
            REPLACE(SYS_CONNECT_BY_PATH(RPAD('HIREDATE:' || TO_CHAR(hiredate,'DD-MON-YY'),30),','),',') ||
            CHR(13) || CHR(10) || '       ' ||
            REPLACE(SYS_CONNECT_BY_PATH(RPAD('SAL:' || sal,30),','),',') ||
            LPAD(CHR(13) || CHR(10),2 * :blank_lines,CHR(13) || CHR(10)) line
      FROM  t
      WHERE CONNECT_BY_ISLEAF = 1
      START WITH mod(rn,:column_count) = 1
      CONNECT BY rn = PRIOR rn + 1
             AND level <= :column_count
    /For example:
    SQL> SET LINESIZE 132
    SQL> SET PAGESIZE 0
    SQL> VARIABLE column_count NUMBER
    SQL> EXEC :column_count := 3;
    PL/SQL procedure successfully completed.
    SQL> VARIABLE order_indicator NUMBER
    SQL> EXEC :order_indicator := 1;
    PL/SQL procedure successfully completed.
    SQL> VARIABLE blank_lines NUMBER
    SQL> EXEC :blank_lines := 6;
    PL/SQL procedure successfully completed.
    SQL> WITH t AS (
      2             SELECT  e.*,
      3                     ROW_NUMBER() OVER(ORDER BY CASE :order_indicator
      4                                                  WHEN 1 THEN to_char(empno,'9999')
      5                                                  WHEN 2 THEN ename
      6                                                  WHEN 3 THEN job
      7                                                  WHEN 4 THEN to_char(hiredate,'yyyymmdd')
      8                                                END
      9                                      ) rn
    10               FROM  EMP e
    11            )
    12  SELECT  REPLACE(SYS_CONNECT_BY_PATH(RPAD(TO_CHAR(rn,'999') || '.  EMPNO:' || empno,30),','),',') ||
    13          CHR(13) || CHR(10) || '       ' ||
    14          REPLACE(SYS_CONNECT_BY_PATH(RPAD(ename,30),','),',') ||
    15          CHR(13) || CHR(10) || '       ' ||
    16          REPLACE(SYS_CONNECT_BY_PATH(RPAD(job,30),','),',') ||
    17          CHR(13) || CHR(10) || '       ' ||
    18          REPLACE(SYS_CONNECT_BY_PATH(RPAD('HIREDATE:' || TO_CHAR(hiredate,'DD-MON-YY'),30),','),',') ||
    19          CHR(13) || CHR(10) || '       ' ||
    20          REPLACE(SYS_CONNECT_BY_PATH(RPAD('SAL:' || sal,30),','),',') ||
    21          LPAD(CHR(13) || CHR(10),2 * :blank_lines,CHR(13) || CHR(10)) line
    22    FROM  t
    23    WHERE CONNECT_BY_ISLEAF = 1
    24    START WITH mod(rn,:column_count) = 1
    25    CONNECT BY rn = PRIOR rn + 1
    26           AND level <= :column_count
    27  /
       1.  EMPNO:7369                2.  EMPNO:7499                3.  EMPNO:7521
           SMITH                         ALLEN                         WARD
           CLERK                         SALESMAN                      SALESMAN
           HIREDATE:17-DEC-80            HIREDATE:20-FEB-81            HIREDATE:22-FEB-81
           SAL:800                       SAL:1600                      SAL:1250
       4.  EMPNO:7566                5.  EMPNO:7654                6.  EMPNO:7698
           JONES                         MARTIN                        BLAKE
           MANAGER                       SALESMAN                      MANAGER
           HIREDATE:02-APR-81            HIREDATE:28-SEP-81            HIREDATE:01-MAY-81
           SAL:2975                      SAL:1250                      SAL:2850
       7.  EMPNO:7782                8.  EMPNO:7788                9.  EMPNO:7839
           CLARK                         SCOTT                         KING
           MANAGER                       ANALYST                       PRESIDENT
           HIREDATE:09-JUN-81            HIREDATE:19-APR-87            HIREDATE:17-NOV-81
           SAL:2450                      SAL:3000                      SAL:5000
      10.  EMPNO:7844               11.  EMPNO:7876               12.  EMPNO:7900
           TURNER                        ADAMS                         JAMES
           SALESMAN                      CLERK                         CLERK
           HIREDATE:08-SEP-81            HIREDATE:23-MAY-87            HIREDATE:03-DEC-81
           SAL:1500                      SAL:1100                      SAL:950
      13.  EMPNO:7902               14.  EMPNO:7934
           FORD                          MILLER
           ANALYST                       CLERK
           HIREDATE:03-DEC-81            HIREDATE:23-JAN-82
           SAL:3000                      SAL:1300
    SQL> EXEC :column_count := 4;
    PL/SQL procedure successfully completed.
    SQL> EXEC :blank_lines := 2;
    PL/SQL procedure successfully completed.
    SQL> /
       1.  EMPNO:7369                2.  EMPNO:7499                3.  EMPNO:7521                4.  EMPNO:7566
           SMITH                         ALLEN                         WARD                          JONES
           CLERK                         SALESMAN                      SALESMAN                      MANAGER
           HIREDATE:17-DEC-80            HIREDATE:20-FEB-81            HIREDATE:22-FEB-81            HIREDATE:02-APR-81
           SAL:800                       SAL:1600                      SAL:1250                      SAL:2975
       5.  EMPNO:7654                6.  EMPNO:7698                7.  EMPNO:7782                8.  EMPNO:7788
           MARTIN                        BLAKE                         CLARK                         SCOTT
           SALESMAN                      MANAGER                       MANAGER                       ANALYST
           HIREDATE:28-SEP-81            HIREDATE:01-MAY-81            HIREDATE:09-JUN-81            HIREDATE:19-APR-87
           SAL:1250                      SAL:2850                      SAL:2450                      SAL:3000
       9.  EMPNO:7839               10.  EMPNO:7844               11.  EMPNO:7876               12.  EMPNO:7900
           KING                          TURNER                        ADAMS                         JAMES
           PRESIDENT                     SALESMAN                      CLERK                         CLERK
           HIREDATE:17-NOV-81            HIREDATE:08-SEP-81            HIREDATE:23-MAY-87            HIREDATE:03-DEC-81
           SAL:5000                      SAL:1500                      SAL:1100                      SAL:950
      13.  EMPNO:7902               14.  EMPNO:7934
           FORD                          MILLER
           ANALYST                       CLERK
           HIREDATE:03-DEC-81            HIREDATE:23-JAN-82
           SAL:3000                      SAL:1300
    SQL>     SY.
    Edited by: Solomon Yakobson on Oct 25, 2009 6:02 AM

  • Supress the ROW_ID column in the Select Query.

    Hi,
    I have one custom form and from main form I am calling the Line Form.
    But when I am clicking the LINE button then Form is getting open but it is giving one Error message like
    FRM-40505: Oracle Error:unable to perform query
    Once I check the Detail error.
    it is giving me this message.
    ORA-00904: "ROW_ID": invalid identifier
    And I checked the query my query is returning the ROW_ID column.
    Please help on Suppressing the Row_id column getting selected from the query.
    Thanks
    Nihar

    Hi Nihar;
    Please see:
    Transactions Workbench Error: Listing of FRM Errors [ID 1321612.1]
    Regard
    Helios

  • How to create a Type Object with Dynamic select query columns in a Function

    Hi Every One,
    I'm trying to figure out how to write a piplined function that executes a dynamic select query and construct a Type Object in order to assigned it to the pipe row.
    I have tried by
    SELECT a.DB_QUERY INTO actual_query FROM mytable a WHERE a.country_code = 'US';
    c :=DBMS_SQL.OPEN_CURSOR;
    DBMS_SQL.PARSE(c,actual_query,DBMS_SQL.NATIVE);
    l_status := DBMS_SQL.EXECUTE(c);
    DBMS_SQL.DESCRIBE_COLUMNS(c, col_cnt, rec_tab);
    FOR j in 1..col_cnt LOOP
    DBMS_SQL.DEFINE_COLUMN(c,j,v_val,2000);
    END LOOP;
    FOR j in 1..col_cnt LOOP
    DBMS_SQL.COLUMN_VALUE(c,j,v_val);
    END LOOP;
    But got stuck, how to iterate the values and assign to a Type Object from the cursor. Can any one guide me how to do the process.
    Thanks,
    mallikj2

    Hi Justin,
    First of thanks for your reply, and coming to my requirement, I need to report the list of items which are there in the dynamic select statement what am getting from the DB. The select statement number of columns may vary in my example for different countries the select item columns count is different. For US its '15', for UK it may be 10 ...like so, and some of the column value might be a combination or calculation part of other table columns (The select query contains more than one table in the from clause).
    In order to execute the dynamic select statement and return the result i choose to write a function which will parse the cursor for dynamic query and then iterate the values and construct a Type Object and append it to the pipe row.
    Am relatively very new for these sort of things, welcome in case of any suggestions to make it simple (Instead of the function what i thought to work with) also a sample narrating the new procedure will be appreciated.
    Thanks in Advance,
    mallikj2.

Maybe you are looking for