Oracle 11g unpivot query help

Hello,
I have a single row of data showing school term start and end dates in 2011/12. I need to convert this single row of data (containing 16 columns) into 5 rows comprised of just 4 columns (year, term, term_start, term_end).
Is it possible to use just Oracle 11g's unpivot function_ to convert the following 16 columns of data:
select * from
(select 2012 as terms_year,
1 as T1,'05-SEP-2011' as T1_SD, '21-OCT-2011' as T1_ED,
2 as T2,'31-OCT-2011' as T2_SD, '16-DEC-2011' as T2_ED,
3 as T3,'03-JAN-2012' as T3_SD, '10-FEB-2012' as T3_ED,
4 as T4,'20-FEB-2012' as T4_SD, '30-APR-2012' as T4_ED,
5 as T5,'16-APR-2012' as T5_SD, '01-JUN-2012' as T5_ED
from dual) mytable
aka
TERMS_YEAR             T1                     T1_SD       T1_ED       T2                     T2_SD       T2_ED       T3                     T3_SD       T3_ED       T4                     T4_SD       T4_ED       T5                     T5_SD       T5_ED      
2012                   1                      05-SEP-2011 21-OCT-2011 2                      31-OCT-2011 16-DEC-2011 3                      03-JAN-2012 10-FEB-2012 4                      20-FEB-2012 30-APR-2012 5                      16-APR-2012 01-JUN-2012 into the following 4 columns of data (year, term, term_start, term_end):
select terms_year, term, t1_sd as term_start, t1_ed as term_end from
(select 2012 as terms_year, 1 as term, '05-SEP-2011' as T1_SD, '21-OCT-2011' as T1_ED from dual union all
select 2012 as terms_year, 2 as term, '31-OCT-2011' as T2_SD, '16-DEC-2011' as T2_ED from dual union all
select 2012 as terms_year, 3 as term, '03-JAN-2012' as T3_SD, '10-FEB-2012' as T3_ED from dual union all
select 2012 as terms_year, 4 as term, '20-FEB-2012' as T4_SD, '30-APR-2012' as T4_ED from dual union all
select 2012 as terms_year, 5 as term, '16-APR-2012' as T5_SD, '01-JUN-2012' as T5_ED from dual) mytable
aka
TERMS_YEAR             TERM                   TERM_START  TERM_END   
2012                   1                      05-SEP-2011 21-OCT-2011
2012                   2                      31-OCT-2011 16-DEC-2011
2012                   3                      03-JAN-2012 10-FEB-2012
2012                   4                      20-FEB-2012 30-APR-2012
2012                   5                      16-APR-2012 01-JUN-2012 Much obliged if anyone can teach me how - I can't get my head around the pivot/unpivot syntax! E.g.
Select *
From mytable
UNPIVOT (
unpivot_clause
unpivot_for_clause
unpivot_in_clause)
Thanks,
TP.

Hi,
Using the SELECT ... PIVOT feature:
SELECT       terms_year
,       term
,       term_start
,       term_end
FROM       mytable
UNPIVOT       (  ( term
          , term_start
          , term_end
          )     FOR num_col
             IN ( (t1, t1_sd, t1_ed)     AS 1
             , (t2, t2_sd, t2_ed)     AS 2
             , (t3, t3_sd, t3_ed)     AS 3
             , (t4, t4_sd, t4_ed)     AS 4
             , (t5, t5_sd, t5_ed)     AS 5
ORDER BY  terms_year     -- If needed
,            num_col
;The basic syntax for UNPIVOTing to 1 column (plus a label column) is
UNPIVOT (    outcol
     FOR  label     IN ( incol_1  AS label_val_1
                       , incol_2  AS label_val_2
                  , incol_n  AS label_val_n
     )where
outcol       is the pivoted output column, containing values from the original table,
label       is a label column, which will contain values hard-coded in the query,
incol_1, incol_2, ..., incol_n       are the columns from the origianl table to be unpivoted
label_val_1, label_val_2, ..., label_val_n       are the hard-coded values that will go in the label column.
The syntax for pivoting to m columns (m > 1) is like that for pivoting 1 column, but
instead of outcol, you give a comma-delimited list of m outcols, enclosed in parentheses, and
instead of incol_1, incol_2, ... incol_n, you give a comma-delimited list of m columns, enclosed in parentheses.
By the way, storing dates in VARCHAR2 columns is not a very good idea. Use DATE columns instead.
Edited by: Frank Kulash on Jul 16, 2012 6:11 PM

Similar Messages

  • Oracle 11g/R2 Query Result Cache - Incremental Update

    Hi,
    In Oracle 11g/R2, I created replica of HR.Employees table & executed the following statement (+Although using SUM() function is non-logical in this case, but just testifying the result+)
    STEP - 1
    SELECT      /+ RESULT_CACHE */ employee_id, first_name, last_name, SUM(salary)*
    FROM           HR.Employees_copy
    WHERE      department_id = 20
    GROUP BY      employee_id, first_name, last_name;
    EMPLOYEE_ID      FIRST_NAME LAST_NAME     SUM(SALARY)
    202           Pat           Fay          6000
    201           Michael           Hartstein     13000
    Elapsed: 00:00:00.01
    Execution Plan
    Plan hash value: 3837552314
    | Id | Operation           | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT      | | 2 | 130 | 4 (25)| 00:00:01 |
    | 1 | RESULT CACHE      | 3acbj133x8qkq8f8m7zm0br3mu | | | | |
    | 2 | HASH GROUP BY      | | 2 | 130 | 4 (25)| 00:00:01 |
    |* 3 | TABLE ACCESS FULL     | EMPLOYEES_COPY | 2 | 130 | 3 (0)| 00:00:01 |
    --------------------------------------------------------------------------------------------------     Statistics
    0 recursive calls
    0 db block gets
    0 consistent gets
    0 physical reads
    0 redo size
    *690* bytes sent via SQL*Net to client
    416 bytes received via SQL*Net from client
    2 SQL*Net roundtrips to/from client
    0 sorts (memory)
    0 sorts (disk)
    2 rows processed
    STEP - 2
    INSERT INTO HR.employees_copy
    VALUES(200, 'Dummy', 'User','[email protected]',NULL, sysdate, 'MANAGER',5000, NULL,NULL,20);
    STEP - 3
    SELECT      /*+ RESULT_CACHE */ employee_id, first_name, last_name, SUM(salary)
    FROM           HR.Employees_copy
    WHERE      department_id = 20
    GROUP BY      employee_id, first_name, last_name;
    EMPLOYEE_ID      FIRST_NAME LAST_NAME SUM(SALARY)
    202      Pat      Fay      6000
    201      Michael      Hartstein      13000
    200      Dummy User      5000
    Elapsed: 00:00:00.03
    Execution Plan
    Plan hash value: 3837552314
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT |          | 3 | 195 | 4 (25)| 00:00:01 |
    | 1 | RESULT CACHE | 3acbj133x8qkq8f8m7zm0br3mu | | | | |
    | 2 | HASH GROUP BY | | 3 | 195 | 4 (25)| 00:00:01 |
    |* 3 | TABLE ACCESS FULL| EMPLOYEES_COPY | 3 | 195 | 3 (0)| 00:00:01 |
         Statistics
    0 recursive calls
    0 db block gets
    4 consistent gets
    0 physical reads
    0 redo size
    *714* bytes sent via SQL*Net to client
    416 bytes received via SQL*Net from client
    2 SQL*Net roundtrips to/from client
    0 sorts (memory)
    0 sorts (disk)
    3 rows processed
    In the execution plan of STEP-3, against ID-1 the operation RESULT CACHE is shown which shows the result has been retrieved directly from Result cache. Does this mean that Oracle Server has Incrementally Retrieved the resultset?
    Because, before the execution of STEP-2, the cache contained only 2 records. Then 1 record was inserted but after STEP-3, a total of 3 records was returned from cache. Does this mean that newly inserted row is retrieved from database and merged to the cached result of STEP-1?
    If Oracle server has incrementally retrieved and merged newly inserted record, what mechanism is being used by the Oracle to do so?
    Regards,
    Wasif
    Edited by: 965300 on Oct 15, 2012 12:25 AM

    965300 wrote:
    Hi,
    In Oracle 11g/R2, I created replica of HR.Employees table & executed the following statement (+Although using SUM() function is non-logical in this case, but just testifying the result+)
    STEP - 1
    SELECT      /+ RESULT_CACHE */ employee_id, first_name, last_name, SUM(salary)*
    FROM           HR.Employees_copy
    WHERE      department_id = 20
    GROUP BY      employee_id, first_name, last_name;
    EMPLOYEE_ID      FIRST_NAME LAST_NAME     SUM(SALARY)
    202           Pat           Fay          6000
    201           Michael           Hartstein     13000
    Elapsed: 00:00:00.01
    Execution Plan
    Plan hash value: 3837552314
    | Id | Operation           | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT      | | 2 | 130 | 4 (25)| 00:00:01 |
    | 1 | RESULT CACHE      | 3acbj133x8qkq8f8m7zm0br3mu | | | | |
    | 2 | HASH GROUP BY      | | 2 | 130 | 4 (25)| 00:00:01 |
    |* 3 | TABLE ACCESS FULL     | EMPLOYEES_COPY | 2 | 130 | 3 (0)| 00:00:01 |
    --------------------------------------------------------------------------------------------------     Statistics
    0 recursive calls
    0 db block gets
    0 consistent gets
    0 physical reads
    0 redo size
    *690* bytes sent via SQL*Net to client
    416 bytes received via SQL*Net from client
    2 SQL*Net roundtrips to/from client
    0 sorts (memory)
    0 sorts (disk)
    2 rows processed
    STEP - 2
    INSERT INTO HR.employees_copy
    VALUES(200, 'Dummy', 'User','[email protected]',NULL, sysdate, 'MANAGER',5000, NULL,NULL,20);
    STEP - 3
    SELECT      /*+ RESULT_CACHE */ employee_id, first_name, last_name, SUM(salary)
    FROM           HR.Employees_copy
    WHERE      department_id = 20
    GROUP BY      employee_id, first_name, last_name;
    EMPLOYEE_ID      FIRST_NAME LAST_NAME SUM(SALARY)
    202      Pat      Fay      6000
    201      Michael      Hartstein      13000
    200      Dummy User      5000
    Elapsed: 00:00:00.03
    Execution Plan
    Plan hash value: 3837552314
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT |          | 3 | 195 | 4 (25)| 00:00:01 |
    | 1 | RESULT CACHE | 3acbj133x8qkq8f8m7zm0br3mu | | | | |
    | 2 | HASH GROUP BY | | 3 | 195 | 4 (25)| 00:00:01 |
    |* 3 | TABLE ACCESS FULL| EMPLOYEES_COPY | 3 | 195 | 3 (0)| 00:00:01 |
         Statistics
    0 recursive calls
    0 db block gets
    4 consistent gets
    0 physical reads
    0 redo size
    *714* bytes sent via SQL*Net to client
    416 bytes received via SQL*Net from client
    2 SQL*Net roundtrips to/from client
    0 sorts (memory)
    0 sorts (disk)
    3 rows processed
    In the execution plan of STEP-3, against ID-1 the operation RESULT CACHE is shown which shows the result has been retrieved directly from Result cache. Does this mean that Oracle Server has Incrementally Retrieved the resultset?
    Because, before the execution of STEP-2, the cache contained only 2 records. Then 1 record was inserted but after STEP-3, a total of 3 records was returned from cache. Does this mean that newly inserted row is retrieved from database and merged to the cached result of STEP-1?
    If Oracle server has incrementally retrieved and merged newly inserted record, what mechanism is being used by the Oracle to do so?
    Regards,
    Wasif
    Edited by: 965300 on Oct 15, 2012 12:25 AMNo, the RESULT CACHE operation doesn't necessarily mean that the results are retrieved from there. It could be being
    written to there.
    Look at the number of consistent gets: it's zero in the first step (I assume you had already run this query before) and I would
    conclude that the data is being read from the result cache.
    In the third step there are 4 consistent gets. I would conclude that the data is being written to the result cache, a fourth step repeating
    the SQL should show zero consistent gets and that would be the results being read.

  • Oracle 11g spatial query

    An Oracle 11g spatial database with 5 features in it. A doughnut, triangle, line, trapezium, pentagon.
    I want to query what coordinates of features exist in a rectange box including the last point that intersects the rectangle box.
    It really difficult to explain without pictures. Please look at this page.
    http://www.h2ss.co.uk/q/question.jsp
    Thanks, I appreciate it.

    Thanks for the replies.
    I acknowledge that what bkzar and jsharma say will work. But in real terms it is impractical for me to create a new table with the SDO_GEOMETRY's. I have over a thousand polygons, each with over 5000 points in my spatial table.
    Let me give you a background to what I am trying to achieve.
    I am trying to extract features from 11g and render them on Google Maps. However some of my polygons are huge and have over 5000 points, Google cannot render them effectively, however Google does give me the coordinates of the visible view, i.e the current rectangle view.
    My idea was that if you are zoomed right into Google Map and a particular feature intersects the rectangle view than I can query for a portion of the feature, including the first and last points that fall outside of the rectangle box.
    I need to be able to somehow filter the SDO_GEOMETRY that don't exist in the rectangle box.
    Thanks

  • Oracle 11g X64 installation help

    iam trying to install oracle 11g for x64 on a 64-bit fedora 11 system
    i have configured all the required pre-requisites properly,
    after providing password , global database name etc..the installer stops at 91 % , i.e even before the actual installation of the software begins
    the information from the oracle installer is at "*processing oracle ultra search server rdbms...*" .
    the installer doesnt seem to move forward from here
    please help me fixing the problem
    thanks and regards
    vamsi

    No help is possible given two facts:
    1. I've never seen it happen.
    2. I've never tried to install on an unsupported operating system.
    Blow away Fedora and download Oracle Enterprise Linux (http://otn.oracle.com)
    Then cut and paste your way through the configuration using the samples under "Linux" in Morgan's Library at www.morganslibrary.org/library.html.
    It is no small number of times, each week, that people with Fedora and other unsupported distros have problems and ask for help.
    I can not recall a single person using OEL or RedHat that has posted a request for help here. Perhaps there is a reason. <g>

  • Problem Installing Oracle 11g. Please Help!

    Hello All,
    I need to install Oracle 11g Release 2  database on my machine:
    Windows 7 Enterprise
    64 bit Operating System
    Service Pack 1
    I ran into problems right before  I reach the Installation Options Screen
    The error message is:
    Unable to establish a network connection to proxy server. Specify the correct proxy details.
    I have tried entering the correct Proxy server information but it gives me the same error.
    Please Help
    Thanks

    HI,
    If you are not using proxy or if you want to continue without connecting to internet, you can just continue without providing these details
    Regards
    Yoonas

  • Oracle 11g : UTL_FILE query

    Hi,
    I am having 2 server. One server has oracle database while on another one is application server where all the data files and application specific shell scripts are kept. We are connecting to database via the application server.
    I am using Oracle 11g:
    Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
    PL/SQL Release 11.1.0.6.0 - Production
    CORE 11.1.0.6.0 Production
    TNS for HPUX: Version 11.1.0.6.0 - Production
    NLSRTL Version 11.1.0.6.0 - Production
    I know that using UTL_FILE in PL/SQL procedure we can create file on the server (where oracle is installed).
    My requirement is generated some report which will involve writing to more than 2 files simultaneously. I know I can easily do this in PL/SQL procedure.
    But my issue is that due to space issue I cannot generate the files on database server and need to generate the same on the application one (client side)
    Queries:
    1] Is it also possible to create file on client machince instead of server in my case the application server via PL/SQL because I read that in Oracle 11g
    UTL_FILE provides file access both on the client side and on the server side.
    2] If yes any idea, how is this possible?
    3] If not, is there any way by which I can write to 2 or more file simultaneously on the client using oralce. I know SQL*Plus can spool file on client. But it is only one file at a time.
    Rgds,
    Amol

    Looking at the 11g documentation you are probably referring to:
    http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28419/u_file.htm#BABDEJDH
    where it says...
    >
    UTL_FILE provides file access both on the client side and on the server side. When run on the server, UTL_FILE provides access to all operating system files that are accessible from the server. On the client side, as in the case for Forms applications, UTL_FILE provides access to operating system files that are accessible from the client.
    >
    This is referring to client installed forms applications where it provides a local UTL_FILE functionality that accesses the local file system. It doesn't mean that UTL_FILE within PL/SQL that is running on the database server can access the client machine's file system as this would also be a breach of network security.

  • Oracle 11g Certification Query

    Hi all,
    I have given my Oracle 11g exams for OCP certification. Now, i need to take one of the mandatory training to fulfill the requirements for certification. I am in Kuwait and when i select the country as Kuwait, the cheapest training course is of $1230. I am an indian, so when i select the country as India on the oracle site, the price reduces down to $540 for the same course. This is for the Live Virtual Class (LVC) rates. Can i book the LVC with India as country. Do I have to be present in India for the LVC training or only taking a course is compulsion.
    Kindly advice.

    Zuzar Sajjad Tutawala wrote:
    Hi all,
    I have given my Oracle 11g exams for OCP certification. Now, i need to take one of the mandatory training to fulfill the requirements for certification. I am in Kuwait and when i select the country as Kuwait, the cheapest training course is of $1230. I am an indian, so when i select the country as India on the oracle site, the price reduces down to $540 for the same course. This is for the Live Virtual Class (LVC) rates. Can i book the LVC with India as country. Do I have to be present in India for the LVC training or only taking a course is compulsion.
    Kindly advice.If you take LVC training my understanding, and it has been discussed in previous threads, if you need to be prsent in the country from which hte LVC is being presented. So if you want to take it in India you will need to travel back there.

  • Unpivot query help

    Hi ALL
    I have the following sample data:
    AMENDMENT_DATES_ID     AMENDMENT_ID     ENTRY_DATE     AMENDMENT_DATE_CODE
    29710     1     12/20/2007     15
    31852     2     1/17/2006     29
    31860     3     2/9/2006     29
    31868     4     9/13/2007     29
    31876     6     3/28/2006     29
    29994     88     11/21/2007     6
    31890     9     8/23/2006     29
    I tried to create seperate fields based on the "AMENDMENT_DATE_CODE" using CASE AND DECODE but was not successful. I need the values of the field "AMENDMENT_DATE_CODE" as seperate fields, like :
    AMENDMENT_DATES_ID AMENDMENT_ID ENTRY_DATE 15 29 6
    Please need help.
    Thanks

    Hi,
    Unpivot means display multiple columns from one row as if they were one column on multiple rows.
    It looks like you want to do the opposite: display the same column from 3 rows as 3 columns on 1 row. That's called Pivot .
    This thread shows what you need:
    Help for a query to add columns
    That example used the aggregate COUNT; you'll probably want MIN or MAX instead. If the combination (AMENDMENT_DATES_ID, AMENDMENT_ID, ENTRY_DATE, AMENDMENT_DATE_CODE) is unique, it won't matter whethere you use MIN or MAX; when there's no more than 1 item, the largest one is the same as the smallest.
    As you can see from that thread, there is a different (better) way of doing pivots starting in Oracle 11. What version are you using?
    If you'd like help, post a little sample data (CREATE TABLE and INSERT statements), the results you want from that data, and your best attempt at a query.

  • Oracle 11g :SELECT query blocked..??

    Hi Experts,
    could you please explain why the below SQL query is blocked?
    SELECT 1 FROM DUAL is blocking the SQL statement on GTTAPPUSR@gttccuatcriba04 ( SID=469 ) blocked SQL -> DELETE FROM GTTDB.PURCHASE_ENTRY_ID=:1
    SELECT 1 FROM DUAL is blocking the SQL statement on GTTAPPUSR@gttccuatcriba04 ( SID=367 ) blocked SQL -> DELETE FROM GTTDB.PURCHASE_ENTRY_ID=:1
    I am scratching my head without any solution when I had a look at the db today. Thanks in advance for your help.
    Regards,
    Boris
    Edited by: user12075620 on Dec 4, 2012 8:58 AM

    The SELECT statement is not blocking the UPDATE. As I said in the previous reply, the string that this query produces does not match the logic.
    This query is (at least on the surface) correctly identifying that session 1 is blocking session 2. Session 1 holds some lock that session 2 is waiting on. So far, so good. Since session 2 is waiting on the lock, we can easily enough see what session 2 is running (the UPDATE statement). But since session 1 is not blocked, it is potentially off running a ton of other SQL statements (or no SQL statement at all). The query is looking to see what session 1 is running currently. It has no way of determining what session 1 ran at some point in the past to acquire the lock in the first place.
    Going back to my KING example,
    At noon, session 1 runs
    UPDATE emp
       SET sal = sal * 2
    WHERE ename = 'KING'Session 1 now has a lock on the KING row in the EMP table. But session 1 neither commits nor rolls back, it is still in a transaction. Session 1 might not have any more activity for a long time-- the user might go off to lunch, for example (obviously, applications should not be designed to allow users to maintain open transactions indefinitely, but not all applications are designed correctly). Or it might start running other queries. Let's say that session 1 now runs a query that is going to go for an hour
    SELECT *
      FROM giant_view_with_lots_of_computationsNow, at 12:45, session 2 comes in and runs
    UPDATE emp
       SET bonus = 100
    WHERE ename = 'KING'Session 2 is blocked. Session 2 is running the UPDATE statement. Session 1 still holds the lock but it is running some completely unrelated SQL statement.
    If we run the query you posted, the query will correctly report that session 1 is running the query against the GIANT_VIEW_WITH_LOTS_OF_COMPUTATIONS but incorrectly imply that this SELECT query is the source of the lock. It is not. It simply happens to be the query that the session that does hold the lock happens to be executing at the current moment (why the application seems to be running a lot of queries that select a constant from dual is a separate question).
    Justin

  • How to convert SQL server stored procedures to Oracle 11g

    Hi Experts,
    In SQL server 30 stored procedures are there how to convert all the stored procedure
    from SQL server to Oracle 11g.
    Please help me,
    Thanks.

    ramya_162 wrote:
    In SQL server 30 stored procedures are there how to convert all the stored procedure
    from SQL server to Oracle 11g.
    The single most fundamental concept you need to understand (grok in its fullness) is:
    ORACLE IS NOT SQL-SERVER
    There is very little, to NOTHING, in common between T-SQL (a language extension to SQL) and PL/SQL (integration of SQL with the language Ada, part of ALGOL family of languages that includes Pascal and C++).
    So taking a T-SQL procedure and porting it as is to PL/SQL is plain stupid.
    Why?
    Oracle sucks at trying to be SQL-Server.
    So how do you migrate from SQL-Server to Oracle?
    By taking the REQUIREMENTS that the T-SQL procedures address, and addressing these requirements using Oracle SQL and PL/SQL.

  • Can I use oracle client 10g express to work on oracle 11g database

    I have installed an oracle DB 11g, I also installed oracle client 10g express edition to create users and tables. I noticed that the users I created can't connect to db with error message "Error java.sql.SQLException: ORA-01017: invalid username/password; logon denied" and tables I created can't access from my program. I get error message "Error java.sql.SQLException: ORA-00942: table or view does not exist". I start to suspect that client 10g express edition can't use with oracle 11g. Please help.
    any suggestion is appreciated.
    Thanks,
    -- Allen --

    Microsoft Windows XP [Version 5.1.2600]
    (C) Copyright 1985-2001 Microsoft Corp.
    C:\temp>cd \oracle\app\oracle\product\10.2.0\server\BIN
    C:\oracle\app\oracle\product\10.2.0\server\BIN>
    C:\oracle\app\oracle\product\10.2.0\server\BIN>cd \temp
    C:\Temp>set ORACLE_HOME=C:\oracle\app\oracle\product\10.2.0\server
    C:\Temp>set ORACLE_SID=XE
    C:\Temp>set PATH=%ORACLE_HOME%\bin;%PATH%
    C:\Temp>type C:\oracle\app\oracle\product\10.2.0\server\NETWORK\ADMIN\tnsnames.o
    ra
    XE =
      (DESCRIPTION =
        (ADDRESS = (PROTOCOL = TCP)(HOST = FCC003L)(PORT = 1521))
        (CONNECT_DATA =
          (SERVER = DEDICATED)
          (SERVICE_NAME = XE)
    TEST =
      (DESCRIPTION =
        (ADDRESS = (PROTOCOL = TCP)(HOST = FCC003L)(PORT = 1521))
        (CONNECT_DATA =
          (SERVER = DEDICATED)
          (SERVICE_NAME = TEST)
    ORA11B =
      (DESCRIPTION =
        (ADDRESS = (PROTOCOL = TCP)(HOST = LAB2)(PORT = 1521))
        (CONNECT_DATA =
          (SERVER = DEDICATED)
          (SERVICE_NAME = ORA11B.example.com)
    EXTPROC_CONNECTION_DATA =
      (DESCRIPTION =
        (ADDRESS_LIST =
          (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC_FOR_XE))
        (CONNECT_DATA =
          (SID = PLSExtProc)
          (PRESENTATION = RO)
    ORACLR_CONNECTION_DATA =
      (DESCRIPTION =
        (ADDRESS_LIST =
          (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC_FOR_XE))
        (CONNECT_DATA =
          (SID = CLRExtProc)
          (PRESENTATION = RO)
    C:\Temp>sqlplus system/oracle@ora11b
    SQL*Plus: Release 10.2.0.1.0 - Production on Thu Jul 3 18:26:14 2008
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - ProductionWith the Partitioning, Oracle Label Security, OLAP, Data Mining,
    Oracle Database Vault and Real Application Testing options
    SQL> exit
    Disconnected from Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Pr
    oduction
    With the Partitioning, Oracle Label Security, OLAP, Data Mining,
    Oracle Database Vault and Real Application Testing options
    C:\Temp>

  • 11G Pivot Query with Oracle EBS

    Hello all,
    We are trying to use the 11G pivot query function with data from Oracle E-Business Suite. We have an 11G database installed with our Oracle APEX. We cannot seem to get the pivot function to work. At a glance, would anyone be able to see any glaring errors in our syntax. I am not certain it is possible to provide test data so...
    We are trying to have column headings with the Period Names SEP-08 OCT-08 NOV-08, with rows of segment2 007751 and accounted_dr as the dataset.
    When we run the sql we get an error ORA-00904: "PERIOD_NAME": invalid identifier.
    Any help or insight would be greatly appreciated.
    select * from (
    select segment2, accounted_dr, period_name
    from gl_je_lines a, gl_code_combinations b
    where b.code_combination_id = a.code_combination_id
    and segment2 = '007751')
    pivot
    sum(accounted_dr)
    for period_name in ('SEP-08','OCT-08','NOV-08')
    group by segment2, period_name

    lilhelp wrote:
    Hello all,
    We are trying to use the 11G pivot query function with data from Oracle E-Business Suite. We have an 11G database installed with our Oracle APEX. We cannot seem to get the pivot function to work. At a glance, would anyone be able to see any glaring errors in our syntax. I am not certain it is possible to provide test data Why not?
    >
    We are trying to have column headings with the Period Names SEP-08 OCT-08 NOV-08, with rows of segment2 007751 and accounted_dr as the dataset.
    When we run the sql we get an error ORA-00904: "PERIOD_NAME": invalid identifier.
    Any help or insight would be greatly appreciated.
    select * from (
    select segment2, accounted_dr, period_name
    from gl_je_lines a, gl_code_combinations b
    where b.code_combination_id = a.code_combination_id
    and segment2 = '007751')
    pivot
    sum(accounted_dr)
    for period_name in ('SEP-08','OCT-08','NOV-08')
    group by segment2, period_nameDon't use GROUP BY. When you use PIVOT, the grouping is implied by what is in the PIVOT clause and what is not.
    Try this:
    select    *
    from        (
           select  segment2
           ,       accounted_dr
           ,       period_name
           from       gl_je_lines          a
           ,       gl_code_combinations     b
           where       b.code_combination_id = a.code_combination_id
           and       segment2 = '007751'
    pivot       (
           sum (accounted_dr)
           for period_name in ('SEP-08','OCT-08','NOV-08')
    ;which is just your posted query without the GROUP BY clause.

  • Oracle 11G - Oracle AWR export import Query Statistics.

    I have Oracle 11G, i have seen the sql statements through Historical AWR option from Top Activites in performance tab. Can i export all AWR query statistics from production machine so that i can analyze all logs after importing it.
    How can i know all statistical sql ( information ) and performace of production machine ?
    any help ?

    Hello,
    have you checked the DBA_HIST* objects to see what / how was imported?
    If the awr export dosn't get the contents of the rolling buffer, then you won't see any session statistics that are only there. If you want to get the contents of the rolling buffer you have to dump the contents of it with :
    oradebug setmypid
    oradebug dump ashdump 10
    and load it into your "test" database.
    But before doing this I suggest you read the related metalink documentation if any!!!
    Regards,
    Franky

  • Oracle 11G - Oracle AWR query execution time in report

    I have used AWR tool of oracle 11G. I have exported query historical statistics of production databaser using awrextr.sql and then load the exported dump file using awrload.sql script.
    Then i used awrrpti.sql and awrsqrpi.sql for generating report of sql queries. Every thing is working fine and generated reports are also very helpful, but report does not show the exact time when the query was executed. How can i get the actual time when the query was executed ?
    any help please ?

    If you would have consulted the Oracle Reference Manual to get the view descriptions, you should have your question is a rhetorical one with the answer NO.
    This is because every statement can be executed one or more times, and Oracle would need to keep track of all individual executions.
    I do agree most 'applications' do not use bind variables, and consequently only have unique statements, but Oracle didn't take that into account, and rightly so.
    Sybrand Bakker
    Senior Oracle DBA

  • Oracle 10g vs Oracle 11g query performance

    Hi everyone,
    We are moving from Oracle 10g to Oracle 11g database.
    I have a query which in Oracle 1g takes 85 seconds to run, but when I run the same query in Oracle 11g database, it takes 635 seconds.
    I have confirmed that all indexes on tables involved are enabled.
    Does anyone have any pointers, what should I look into. I have compared explain plans and clearly they are different. Oracle 11g is taking a different approach than Oracle 1g.
    Thanks

    Pl post details of OS versions, exact database versions (to 4 digits) and init.ora parameters of the 10g and 11g databases. Have statistics been gathered after the upgrade ?
    For posting tuning requests, pl see these threads
    HOW TO: Post a SQL statement tuning request - template posting
    When your query takes too long ...
    Pl see if the SQL Performance Analyzer can help - MOS Doc 562899.1 (TESTING SQL PERFORMANCE IMPACT OF AN ORACLE 9i TO ORACLE DATABASE 10g RELEASE 2 UPGRADE WITH SQL PERFORMANCE ANALYZER)
    HTH
    Srini

Maybe you are looking for

  • Proxy error while running the financial report in workspace.

    Hi, We are using the Hyperion financial reporting 9.3.1 with Essbase as a data source. While running a report in workspace, we are getting the 'Proxy error' meassage, which is following- "<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> '<html><hea

  • Multi-map without using BPM

    Hello I am trying to create a multimap without using BPM as we are on SP15. I did the respective configuration in Message and Interface mapping as mentioned in the weblog. I am expecting multiple files to get generated in the target directory and i h

  • Profile configuration for my app

    Is it possible to set preference values for my app in the profile configuration file? If so, an example would be greatly appreciated. Thanks.

  • How to disable a ipod 5th gen and how to get the passcode ?

    I just bought ant ipod 5th gen from Americans store but it was a display when I got ready to set it up it don't let me go pass the disable  connect to iTunes screen. I try restoring it but it don't let me it takes about 1 hour to load and then it get

  • Parsing escape sequences

    Hey, I've been stumped on this for a while; I have an application which reads the contents of a text file to obtain encrypted strings, which use escape sequences in them. I can only decrypt them once these escape sequences have been "parsed," per say