CURSOR on a temp table?

hello
*okay this following is WORKING and CORRECT:*
CREATE OR REPLACE FUNCTION fnGetParents
ObjectId number,
ObjectClassifier varchar2
RETURN typescursorType
IS
fnGetParents_cursor types.cursorType;
BEGIN
EXECUTE IMMEDIATE (''CREATE GLOBAL TEMPORARY TABLE TMP_HierarchyMap
Id numeric(19,0) NOT NULL,
ParentId numeric(19,0) NOT NULL,
ChildId numeric(19,0) NOT NULL,
) on commit delete rows'');
EXECUTE IMMEDIATE (''CREATE GLOBAL TEMPORARY TABLE TEMP_ID
Id numeric(19,0) NOT NULL,
bDone NUMERIC(1,0) NOT NULL
) on commit delete rows'');
/* recursive call: spRecursiveGetParents(ObjectId, ObjectClassifier); */
OPEN fnGetParents_cursor FOR
SELECT
Id,
ParentId,
ChildId,
FROM TMP_HierarchyMap;
RETURN fnGetParents_cursor;
END fnGetParents;
My question is, how can I do something like this:
EXECUTE IMMEDIATE 'CREATE OR REPLACE TYPE TmpHierarchyMapObjType AS OBJECT
Id numeric(19,0) ,
ParentId numeric(19,0),
ChildId numeric(19,0),
EXECUTE IMMEDIATE 'CREATE OR REPLACE TYPE TmpHierarchyMapTableType AS TABLE OF TmpHierarchyMapObjType;';
EXECUTE IMMEDIATE 'CREATE OR REPLACE PACKAGE types AS
TYPE cursorType IS REF CURSOR;
END; ';
CREATE OR REPLACE FUNCTION fnGetParents
ObjectId number,
ObjectClassifier varchar2
RETURN typescursorType
IS
TmpHierarchyMap TmpHierarchyMapTableType := TmpHierarchyMapTableType();
fnGetParents_cursor types.cursorType;
BEGIN
EXECUTE IMMEDIATE (''CREATE GLOBAL TEMPORARY TABLE TMP_HierarchyMap
Id numeric(19,0) NOT NULL,
ParentId numeric(19,0) NOT NULL,
ChildId numeric(19,0) NOT NULL,
) on commit delete rows'');
EXECUTE IMMEDIATE (''CREATE GLOBAL TEMPORARY TABLE TEMP_ID
Id numeric(19,0) NOT NULL,
bDone NUMERIC(1,0) NOT NULL
) on commit delete rows'');
/* recursive call: spRecursiveGetParents(ObjectId, ObjectClassifier); */
OPEN fnGetParents_cursor FOR
SELECT
Id,
ParentId,
ChildId,
FROM TMP_HierarchyMap;
-- I want to learn how to enumerate a temp table and put it in a nested table but keep getting error on loop
FOR oMap in spGetChildren_cursor LOOP
                         TmpHierarchyMap.Extend();
                         TmpHierarchyMap(TmpHierarchyMap.Count) := TmpHierarchyMapObjType( oMap.Id                                                                                               ,oMap.ParentId                                                                                               , oMap.ChildId
                    END LOOP;
RETURN fnGetParents_cursor;
END fnGetParents;
I just want to know how for sake of learning.
Thanks

As mentioned yesterday, if you create database objects dynamically, you have to query them dynamically.
For example, you could use the DBMS_SQL package, which offers one of the most flexible ways of dyanamic queries..
[DBMS_SQL Package|http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_sql.htm#sthref6136]
CREATE OR REPLACE PROCEDURE run_query(p_sql IN VARCHAR2) IS
  v_finaltxt  VARCHAR2(4000);
  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;
BEGIN
  c := DBMS_SQL.OPEN_CURSOR;
  DBMS_SQL.PARSE(c, p_sql, DBMS_SQL.NATIVE);
  d := DBMS_SQL.EXECUTE(c);
  DBMS_SQL.DESCRIBE_COLUMNS(c, col_cnt, rec_tab);
  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);
      WHEN 2 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_n_val);
      WHEN 12 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_d_val);
    ELSE
      DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
    END CASE;
  END LOOP;
  FOR j in 1..col_cnt
  LOOP
    v_finaltxt := ltrim(v_finaltxt||','||lower(rec_tab(j).col_name),',');
  END LOOP;
  DBMS_OUTPUT.PUT_LINE(v_finaltxt);
  LOOP
    v_ret := DBMS_SQL.FETCH_ROWS(c);
    EXIT WHEN v_ret = 0;
    v_finaltxt := NULL;
    FOR j in 1..col_cnt
    LOOP
      CASE rec_tab(j).col_type
        WHEN 1 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_v_val);
                    v_finaltxt := ltrim(v_finaltxt||',"'||v_v_val||'"',',');
        WHEN 2 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_n_val);
                    v_finaltxt := ltrim(v_finaltxt||','||v_n_val,',');
        WHEN 12 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_d_val);
                    v_finaltxt := ltrim(v_finaltxt||','||to_char(v_d_val,'DD/MM/YYYY HH24:MI:SS'),',');
      ELSE
        v_finaltxt := ltrim(v_finaltxt||',"'||v_v_val||'"',',');
      END CASE;
    END LOOP;
    DBMS_OUTPUT.PUT_LINE(v_finaltxt);
  END LOOP;
  DBMS_SQL.CLOSE_CURSOR(c);
END;
SQL> exec run_query('select * from emp');
empno,ename,job,mgr,hiredate,sal,comm,deptno
7369,"SMITH","CLERK",7902,17/12/1980 00:00:00,800,,20
7499,"ALLEN","SALESMAN",7698,20/02/1981 00:00:00,1600,300,30
7521,"WARD","SALESMAN",7698,22/02/1981 00:00:00,1250,500,30
7566,"JONES","MANAGER",7839,02/04/1981 00:00:00,2975,,20
7654,"MARTIN","SALESMAN",7698,28/09/1981 00:00:00,1250,1400,30
7698,"BLAKE","MANAGER",7839,01/05/1981 00:00:00,2850,,30
7782,"CLARK","MANAGER",7839,09/06/1981 00:00:00,2450,,10
7788,"SCOTT","ANALYST",7566,19/04/1987 00:00:00,3000,,20
7839,"KING","PRESIDENT",,17/11/1981 00:00:00,5000,,10
7844,"TURNER","SALESMAN",7698,08/09/1981 00:00:00,1500,0,30
7876,"ADAMS","CLERK",7788,23/05/1987 00:00:00,1100,,20
7900,"JAMES","CLERK",7698,03/12/1981 00:00:00,950,,30
7902,"FORD","ANALYST",7566,03/12/1981 00:00:00,3000,,20
7934,"MILLER","CLERK",7782,23/01/1982 00:00:00,1300,,10
PL/SQL procedure successfully completed.
SQL> exec run_query('select * from dept');
deptno,dname,loc
10,"ACCOUNTING","NEW YORK"
20,"RESEARCH","DALLAS"
30,"SALES","CHICAGO"
40,"OPERATIONS","BOSTON"
PL/SQL procedure successfully completed.Or you could build up a query to use with execute immediate, but then you will need to ensure you know what columns you expect as output.

Similar Messages

  • Global Temp table Vs Regular table

    Hi,
    I need a temp table to store few IDs (which I select from a complex query). I would be deleting the data from the temp table at the end of the session.
    From a performance perspective, I was wondering if I should be using a GLOBAL temporary table or just a regular table in which I will manually delete rows at the end.
    The tkprof showed using the global temp table expensive. If yes, I just want to confirm it and know why it is the case.
    Thanks!
    Anand

    Assuming that the cursor you open to get the transaction_id actually has a where clause, and refraining from comment on the need for dynamic column lists, I would likely do it something like:
    DECLARE
       lv_query   VARCHAR2 (32767);
       l_col_list VARCHAR2(4000);
    BEGIN
       l_col_list := control_module_common_pkg.get_columns('EPOS_TRANSACTION_HEADER',
                                                           FALSE);
       lv_query := 'INSERT INTO AK_TRANSACTION_HEADER ('||l_col_list||
                   ' ) SELECT '||l_col_list||' FROM EPOS_TRANSACTION_HEADER
                   WHERE ETH_TRANSACTION_ID IN (SELECT eth_transaction_id
                                                FROM epos_transaction_header
                                                WHERE <whatever would be in the cursor>)';
       EXECUTE IMMEDIATE lv_query;
       COMMIT;
    END;If there really is no where clause ion the cursor, then it would simply be:
    DECLARE
       lv_query   VARCHAR2 (32767);
       l_col_list VARCHAR2(4000);
    BEGIN
       l_col_list := control_module_common_pkg.get_columns('EPOS_TRANSACTION_HEADER',
                                                           FALSE);
       lv_query := 'INSERT INTO AK_TRANSACTION_HEADER ('||l_col_list||
                   ' ) SELECT '||l_col_list||' FROM EPOS_TRANSACTION_HEADER';
       EXECUTE IMMEDIATE lv_query;
       COMMIT;
    END;In either case, I would also re-consider the commit in the procedure. It should perhaps be the caller of this procedure that issues the commit, not the procedure itself.
    John

  • How do I CREATE IF NOT EXISTS Temp table in PLSQL?

    hello, how do I CREATE IF NOT EXISTS Temp table in PLSQL? The following table is to be created in FIRST call inside a recursive function (which you'll see in QUESTION 2).
    QUESTION 1:
    CREATE GLOBAL TEMPORARY TABLE TmpHierarchyMap
                                  Id numeric(19,0) NOT NULL,
                                  ParentId numeric(19,0) NOT NULL,
                                  ChildId numeric(19,0) NOT NULL,
    ... more ...
                             ) on commit delete rows');
    QUESTION 2: How to return a temp table from a function?
    For example, this is how I'm doing it at the moment, using Nested Table.
    EXECUTE IMMEDIATE 'CREATE OR REPLACE TYPE TmpHierarchyMapObjType AS OBJECT
                   Id numeric(19,0) ,
                   ParentId numeric(19,0),
                   ChildId numeric(19,0),
    ... more ...
         EXECUTE IMMEDIATE 'CREATE OR REPLACE TYPE TmpHierarchyMapTableType AS TABLE OF TmpHierarchyMapObjType;';
    CREATE OR REPLACE FUNCTION fnGetParentsTable
    ObjectId number,
    ObjectClassifier varchar2
    RETURN TmpHierarchyMapTableType
    IS
    TmpHierarchyMap TmpHierarchyMapTableType := TmpHierarchyMapTableType();
    ThisTempId varchar2(32);
    CURSOR spGetParents_cursor IS
    SELECT
    Id,
    ParentId,
    ChildId,
    FROM TMP_HIERARCHYMAP
    WHERE TempId = ThisTempId;
    BEGIN
    SELECT sys_guid() INTO ThisTempId FROM dual;
    spRecursiveGetParents(ObjectId, ObjectClassifier, ThisTempId);
    FOR oMap in spGetParents_cursor LOOP
    TmpHierarchyMap.Extend();
    TmpHierarchyMap(TmpHierarchyMap.Count) := TmpHierarchyMapObjType( oMap.Id
    , oMap.ParentId
    , oMap.ChildId
    END LOOP;
    DELETE FROM TMP_HIERARCHYMAP WHERE TempId = ThisTempId;
    RETURN TmpHierarchyMap;
    END fnGetParentsTable;
    QUESTION 3: what does the word GLOBAL means? I read that temp table is visible only to a particular database connection/session and will be dropped automatically on termination of the session. i can only find this information in some forum discussion but failed to locate this in Oracle doc, can someone point me in right direction please?
    Many thanks!
    REF:
    http://stackoverflow.com/questions/221822/sybase-developer-asks-how-to-create-a-temporary-table-in-oracle
    http://www.oracle-base.com/articles/8i/TemporaryTables.php

    devvvy wrote:
    so if I CREATE GLOBAL TEMPORARY TABLE twice on second pass of my recursive function what then...?You don't create it inside your function.
    You create the GTT once on your database outside of the function and then just leave it there and use it.
    Tables should not be dynamically created and dropped.
    Only other database engines such as SQL Server use the concept of creating temporary tables during the execution of code. Oracle uses a "create once, use whenever" methodology.

  • How to work on temp table in oracle 10g

    Hi Guys,
    I have one simple procedure and it is returning some records through dbms_output.put_line.
    cursor c1 is select object_name from t_Turbo;
    type c1_type is table of c1%rowtype;
    rec1 c1_type;
    begin
    open c1;
    loop
    fetch c1 bulk collect into rec1 limit 200;
    for i in 1..rec1.count loop
    dbms_output.put_line(rec1.i);
    end loop;
    exit when c1%notfound;
    end loop;
    end;
    Now i am plaing to use temp table at dmbs_output.put_line in place and from there I want to select the records.
    Can any one help me on this.
    Thanks in advance!
    Regards,
    KLR

    This is what you need.
    create or replace procedure test ( pRet out sys_refcursor )
    as
    begin
      open pRet for select object_name from t_Turbo;
    end;SYS_REFCURSOR is a cursor type defined by oracle. You can define your owner.

  • Two temp tables in a Stored Procedure

    Hi guys,
    Is it feasable to use two stored procedures and form joins between them within a single stored procedure. I am trying a workaround for cursors in SYBASE.
    Thanks,
    Developer

    This Create a temporary table in stored proc is a long and occasionally fractious discussion of the differences between temp tables in Oracle and MS SQL Server (and hence Sybase). You may wish to review it, or at least the links to the documentation.
    Alternatively, expalin what it is the sybase code is doing and we will tell the best way to implement it in Oracle.
    Cheers, APC

  • Update Global Temp Table in Oracle 11g

    Hi Experts,
    Scenario: I have stored  procedure A which calls procedure B. Procedure B uses Global temp Tables(With On Commit Preserve Rows)  to work with the data.
    I am trying to update one of the GTT in Proc B but unable to do it .. via SQL or via PL/SQL Cursor/Collection. There is no syntax nor logical error and the PL/SQL proc completes execution successfully but the rows are not getting updated. My Db version is Oralce 11g 11203.
    Update statement is something like this.
    Update <GTT>
    SET amount1 = amount1 *-1, amount2 = amount2 *-1
    where field1 = <value>
    and field2 in ( Select filed2 from <table1> );
    Any idea why would this update not work? Has anyone faced this issue in Oracle 11g??
    Appreciate your suggestions & thanks in Advance for your inputs.
    Cheers,
    MS

    Update statement is something like this.
    Update <GTT>
    SET amount1 = amount1 *-1, amount2 = amount2 *-1
    where field1 = <value>
    and field2 in ( Select filed2 from <table1> );
    Any idea why would this update not work?
    You already told us that it DOES work - no errors or exceptions.
    It is trivial to determine if that update will do anything - just turn it into a SELECT and see if any rows are ntselected:
    v_cnt INTEGER;
    SELECT COUNT(*) INTO v_cnt FROM  myGTT
    WHERE field1 = <value>
    AND field2 in (Select field2 from <tablee1>);
    Then take a look at the 'count' that you get.

  • How can I get rid of Global Temp Table

    Hello,
    I've been writing PL/SQL stored proc for creating reports on VB.NET front end. Until now, I've been using session specific global temp table to store intermediate results and at the end I pass the result set to .NET via reference cursor. The reports are created by simply binding the ref cursor result sets to .NET grids. It's been working fine, but I am kind of bothered by the temp tables. I looked on other options, but couldn't really come up with one.
    Can somebody suggest me how I can get rid of those temp tables? Thanks,

    Tubby, that's exactly I was trying to do. I think that table type has to be defined in database, not within PL/SQL. How can I create that table of user defined record type? I tried that, but it doesn't allow me. I think I am missing something. For example,
    create type group_t is record
    (A varchar2,
    B number,
    C number)
    now inside sp, i have something like:
    type my_group is table of group_t index by binary_integer
    now I have sp cursor as
    cursor cur_test IS 'ABC' as A, 1 as B, 5 as C
    now i do something like this. My original queries are longer and much more complicated so please don't suggest you can directly open ref cursor for this query.
    FETCH cur_test BULK COLLECT INTO my_group;
    Then I do all the processing, calculations, totals, sub-totals, and insert into temp table and return via ref cursor.
    My problem is I can't directly fetch into the above table you mentioned. How should I go about in this situation?
    Maybe I should STOP thinking about this approach and just do whatever I've been doing or solve it through pure SQL. However, there are tons of problems with pure SQL approach.

  • Create temp table using EXECUTE IMMEDIATE

    Is there any performance issue in creating globally temp table
    using EXECUTE IMMEDIATE or creating globally temp table from
    SQL PLUS.
    Any response will be greatly appreciated.
    null

    Anish,
    Creating tables is likely to be an expensive operation.
    Performance issues can only be considered in comparison to
    alternatives.
    Alternatives include: PLSQL tables, cursors and/or recoding so
    that tmp tables are not required. (One of our consultants reckons
    that sqlserver temp tables are usually used to get around
    limitations in sqlserver, ie slightly more complicated sql
    statements could be used instead of simpler sql and temporary
    tables).
    I would think creating the temp table once during sqlplus would
    be cheaper than creating and deleting it repeatedly at run time.
    Note that EXECUTE IMMEDIATE may do an implicit commit (dbms_sql
    certainly does). This may be got over my using the PRAGMA
    AUTONOMOUS_TRANSACTION; direction which places a
    procedure/function in a seperate transaction.
    Turloch
    P.S. We have some difficulty in getting information back from the
    field/customer sites. If you have questions and answers that are
    likely to be useful to other Oracle Migration Workbench
    users, and migrators in general, please send them in for possible
    inclusion in our Frequently Asked Question list.
    Oracle Migration Workbench Team
    Anish (guest) wrote:
    : Is there any performance issue in creating globally temp table
    : using EXECUTE IMMEDIATE or creating globally temp table from
    : SQL PLUS.
    : Any response will be greatly appreciated.
    Oracle Technology Network
    http://technet.oracle.com
    null

  • Visual Basic, DAO, Temp tables in stored procedures

    Client code currently uses DAO with SQLPassthrough option in VB to connect to SQl 6.5 db.
    I migrated all stored procedures with default options except Oracle 8i temp tables. For every procedure a package and a procedure was created. We use SQL server temporary tables extensively in a few hundred stored procedures. The ref cursor created refers to the temporary table. While migratiing, Create table statement is commented. How are SQL6.5 equivalent of temp tables handled in Oracle? Is there an alternative to temp tables?
    I also migrated to another oracle db using the INOUT type for stored procedures. This time only procedures were created. Can these procedures return a record set in DAO with SQLPAssthrough?
    How do you call a procedure using DAO in VB to get recordsets?
    What is the best way to migrate to Oracle with minimal client code changes?
    Thank you in advance.
    Umesh
    null

    Karthick_Arp wrote:
    BluShadow wrote:
    I agree with Karthick, there's no need for a temporary table in this situation.
    And to add, temporary tables should not be created at runtime, they should be part of the initial design of the database, created once and used as needed. Creating them at runtime is just wrong.The problem is the name oracle has given to GTT. The word Temporary mislead lot of SQL Server developers and they think its something same as the temporary table used in SQL Server :)Yeah, Ingres does something similar to SQL Server too, in that you can create a temporary table (Ingres assigned it a unique name and tells you what it is), and you set an expiry time on it (i.e. set it to expire in 1 days time), and then a background process is supposed to clean up the tables that have expired. Unlike Oracle, they are not session specific, but become visible to all once created.
    I think there's room for both types of temporary table, but Oracle's does the job (except when you want to use them from a stateless application front end).

  • Temp Table in Package returning Ref_Cursor?

    I'm new to Oracle. Here is what I'm trying to do.
    I need to lookup all records with a certain ID. The IDs are stored by quarter and year. I'm trying to compare records with the previous 3 quarters.
    so record with ID = 1 also has Qtr = 1, Year = 2008.
    I would also need to find all ID's for the previous 3 quarters ( Q 4 of 2007, Q 3 of 2007, and Q 2 of 2007).
    I'm trying to write a package that will return a ref cursor with all 4 ids so the output would look like a table with 4 rows and 1 column.
    In SQL Server I could create a temp table, insert these 4 values in and return a Select * From TempTable.
    How can I accomplish this in Oracle 10g?

    Something like this ?
    test@ORA10G>
    test@ORA10G> drop table tblyearquarter;
    Table dropped.
    test@ORA10G>
    test@ORA10G> create table tblyearquarter (id, qtr, yr, createdate) as
      2  select
      3    round(dbms_random.value(1,10000)),
      4    t1.qtr,
      5    t2.yr,
      6    (sysdate - t3.indx)
      7  from
      8  (select level+2003 as yr from dual connect by level<=5) t2,
      9  (select level as qtr from dual connect by level<=4) t1,
    10  (select level as indx from dual connect by level<=round(dbms_random.value(1,4))) t3;
    Table created.
    test@ORA10G>
    test@ORA10G> select * from tblyearquarter;
            ID        QTR         YR CREATEDAT
          5059          1       2004 09-MAR-08
          6619          1       2004 08-MAR-08
          5776          1       2004 07-MAR-08
          6943          2       2004 09-MAR-08
          4338          2       2004 08-MAR-08
          8568          2       2004 07-MAR-08
          5878          3       2004 09-MAR-08
          2675          3       2004 08-MAR-08
          4667          3       2004 07-MAR-08
            40          4       2004 09-MAR-08
          1400          4       2004 08-MAR-08
          9509          4       2004 07-MAR-08
          6628          1       2005 09-MAR-08
          4356          1       2005 08-MAR-08
          2439          1       2005 07-MAR-08
          7094          2       2005 09-MAR-08
           482          2       2005 08-MAR-08
          8596          2       2005 07-MAR-08
          4855          3       2005 09-MAR-08
          4447          3       2005 08-MAR-08
          3341          3       2005 07-MAR-08
          5220          4       2005 09-MAR-08
          8461          4       2005 08-MAR-08
          2746          4       2005 07-MAR-08
          3561          1       2006 09-MAR-08
           241          1       2006 08-MAR-08
           108          1       2006 07-MAR-08
          3605          2       2006 09-MAR-08
           310          2       2006 08-MAR-08
           939          2       2006 07-MAR-08
          6611          3       2006 09-MAR-08
          5679          3       2006 08-MAR-08
          3975          3       2006 07-MAR-08
          2238          4       2006 09-MAR-08
          7323          4       2006 08-MAR-08
          8104          4       2006 07-MAR-08
          3206          1       2007 09-MAR-08
          7420          1       2007 08-MAR-08
          7386          1       2007 07-MAR-08
          4237          2       2007 09-MAR-08
          9329          2       2007 08-MAR-08
          6105          2       2007 07-MAR-08
          3800          3       2007 09-MAR-08
          3967          3       2007 08-MAR-08
          8200          3       2007 07-MAR-08
           463          4       2007 09-MAR-08
          9518          4       2007 08-MAR-08
          1451          4       2007 07-MAR-08
          9541          1       2008 09-MAR-08
          1380          1       2008 08-MAR-08
          9320          1       2008 07-MAR-08
          9720          2       2008 09-MAR-08
          4681          2       2008 08-MAR-08
          6431          2       2008 07-MAR-08
          9586          3       2008 09-MAR-08
          8620          3       2008 08-MAR-08
          6859          3       2008 07-MAR-08
          5883          4       2008 09-MAR-08
           548          4       2008 08-MAR-08
          4647          4       2008 07-MAR-08
    60 rows selected.
    test@ORA10G>
    test@ORA10G> select id, qtr, yr
      2    from (select id, qtr, yr, rownum as rnum
      3            from (select id, qtr, yr, createdate
      4                    from (select id,
      5                                 qtr,
      6                                 yr,
      7                                 createdate,
      8                                 row_number() over(partition by yr, qtr order by createdate desc) as seq
      9                            from tblyearquarter)
    10                   where seq = 1
    11                   order by yr desc, qtr desc)
    12           where yr || qtr <= &year || &quarter)
    13   where rnum <= 4;
    Enter value for year: 2008
    Enter value for quarter: 1
    old  12:          where yr || qtr <= &year || &quarter)
    new  12:          where yr || qtr <= 2008 || 1)
            ID        QTR         YR
          9541          1       2008
           463          4       2007
          3800          3       2007
          4237          2       2007
    test@ORA10G>
    test@ORA10G> /
    Enter value for year: 2007
    Enter value for quarter: 3
    old  12:          where yr || qtr <= &year || &quarter)
    new  12:          where yr || qtr <= 2007 || 3)
            ID        QTR         YR
          3800          3       2007
          4237          2       2007
          3206          1       2007
          2238          4       2006
    test@ORA10G>
    test@ORA10G> /
    Enter value for year: 2006
    Enter value for quarter: 2
    old  12:          where yr || qtr <= &year || &quarter)
    new  12:          where yr || qtr <= 2006 || 2)
            ID        QTR         YR
          3605          2       2006
          3561          1       2006
          5220          4       2005
          4855          3       2005
    test@ORA10G>
    test@ORA10G>pratz

  • Stored procedure with temp table creation inside and using it

    I want to create a temp table inside a stred procedure and make use of it . I want perform some delete statements based on select statemets .An I want to drop the table at the end .
    When I tried to create a table inside the stored procedure using exxecute immediate statement ,.
    sql_stmt := 'CREATE GLOBAL TEMPORARY TABLE pattern_str_temp as select * from pattern_structure';
         EXECUTE IMMEDIATE 'CREATE GLOBAL TEMPORARY TABLE pattern_str_temp as select * from woc_pattern_structure' ;
    Then my select statements that contain this table do not identify the table name.
    I got compilor error when I use it in hte stored procedure in the select statement .Then I did like this-
    WHENEVER SQLERROR CONTINUE
    DROP TABLE pattern_str_temp;
    CREATE TABLE pattern_str_temp AS SELECT * FROM pattern_structure ;
    COMMIT;
    CREATE OR REPLACE PACKAGE BODY Woc_Delete_Model_Data
    AS
    NAME: Woc_Delete_Model_Data
    PURPOSE:
    REVISIONS:
    Ver Date Author Description
    1.0 11/01/2008 gtutika 1. Deletes given Product Model
    PROCEDURE deleteCategory(p_product_model IN varchar2,
                   p_request_status OUT VARCHAR2,
                   p_err_mesg OUT VARCHAR2
    IS
    l_category VARCHAR2(200);
    l_count NUMBER;
    CURSOR getAttribute IS
         SELECT Category_Name
         FROM
    Woc_Attribute_Category
    WHERE Attribute_Name in
    (SELECT Child_Name FROM pattern_structure
    WHERE Child_Type = 'Attribute' and product_Model_Name = p_product_model)
    FOR UPDATE;
    BEGIN
         DBMS_OUTPUT.ENABLE(1000000);
         --dbms_output.put_line('START-Inside DeleteCategory Procedure .........');
         --sql_stmt := 'CREATE GLOBAL TEMPORARY TABLE pattern_str_temp as select * from pattern_structure';
         --EXECUTE IMMEDIATE 'CREATE GLOBAL TEMPORARY TABLE pattern_str_temp as select * from pattern_structure' ;
         OPEN getAttribute ;
    LOOP
         FETCH getAttribute INTO l_category ;
         EXIT WHEN getAttribute%NOTFOUND;
         l_count := Is_Category_Used(p_product_model , l_category);
    IF (l_count=0) THEN
         DELETE FROM WOC_ATTRIBUTE_CATEGORY where CATEGORY_NAME = l_category;
         DELETE from woc_item_category
         where CATEGORY_NAME = l_category;
         DELETE FROM WOC_CATEGORY WHERE CATEGORY_NAME = l_category;
    END IF;
         END LOOP;
         --(getAttribute%ROWCOUNT);
         CLOSE getAttribute;
         --dbms_output.put_line('END-Inside DeleteCategory Procedure .........');
    EXCEPTION
         WHEN OTHERS THEN
         dbms_output.put_line(SQLERRM);
              p_err_mesg := 'ERROR IN CUSOR';
              --dbms_output.put_line('ERROR in CUSOR');
              ROLLBACK;
    END;
    FUNCTION Is_Category_Used(p_product_model IN varchar2 , p_category IN Varchar2)
         RETURN NUMBER IS
         l_count NUMBER;
         l_attribute VARCHAR2(40);
         l_pattern varchar2(30);
         CURSOR getAttribute IS
         SELECT attribute_Name from
         WOC_ATTRIBUTE_CATEGORY WHERE category_name = p_category and Attribute_Name in
         (Select Child_Name from pattern_str_temp
         where child_type = 'Attribute' and product_Model_Name = p_product_model);
    BEGIN
    DBMS_OUTPUT.ENABLE(1000000);
         SELECT count(*) into l_count from
         WOC_ATTRIBUTE_CATEGORY WHERE category_name = p_category and Attribute_Name in
         (Select Child_Name from pattern_str_temp
    where child_type = 'Attribute' and product_Model_Name <> p_product_model);
         OPEN getAttribute;
    LOOP
         FETCH getAttribute INTO l_attribute;
         EXIT WHEN getAttribute%NOTFOUND;
         DELETE FROM pattern_str_temp WHERE Product_Model_Name=p_product_model
         and child_type = 'Attribute' and child_Name= l_attribute;
         END LOOP;
         CLOSE getAttribute;
         RETURN l_count;
    EXCEPTION
    WHEN OTHERS THEN
    dbms_output.put_line(SQLERRM);
              --dbms_output.put_line('ERROR in CUSOR');
              ROLLBACK;
    END;
    PROCEDURE delete_batch_woc_model(p_product_model IN VARCHAR2,p_flag IN VARCHAR2,
    p_err_mesg OUT VARCHAR2)
         IS
         p_request_status VARCHAR2(30);
    BEGIN
         deleteCategory(p_product_model,p_request_status ,p_err_mesg );
    EXCEPTION WHEN OTHERS THEN
         dbms_output.put_line(SQLERRM);
              p_err_mesg := 'ERROR IN CUSOR';
              dbms_output.put_line('ERROR in CUSOR');
              ROLLBACK;
    END;
    END Woc_Delete_Model_Data;
    --drop table pattern_str_temp ;
    SHOW ERRORS;
    But once the data is deleted , the data in the temp table is deleted when I load the data and try to delete it agian since I have no data in temp table ,the data is not deleted .So I need to create the temp table every time the stored procedure is called ,delete accordingly and drop the table at the end .
    Please suggest how to do it.
    Thanks.

    I'm not sure I understand what you're attempting to do...
    What is the benefit of a temporary table that stores the same set of data that is in the master table? Why not just
    DELETE FROM child_table1
    WHERE foreign_key IN (
        SELECT primary_key
          FROM master_table
         WHERE some_condition);
    DELETE FROM child_table2
    WHERE foreign_key IN (
        SELECT primary_key
          FROM master_table
         WHERE some_condition);
    DELETE FROM child_table30
    WHERE foreign_key IN (
        SELECT primary_key
          FROM master_table
         WHERE some_condition);
    DELETE FROM master_table
    WHERE some_condition;or
    FOR x IN (SELECT * FROM master_table WHERE some_condition)
    LOOP
      DELETE FROM child_table1 WHERE foreign_key = x.primary_key;
      DELETE FROM child_table2 WHERE foreign_key = x.primary_key;
      DELETE FROM child_table30 WHERE foreign_key = x.primary_key;
      DELETE FROM master_table WHERE primary_key = x.primary_key;
    END LOOP;Justin

  • Data storage in temp tables

    Question 1: I have created a global temporary table tt_groups(grp_ids number) on commit preserve rows; and I was wondering - if I have multiple users accessing this temp table at the same time, do I need to differenciate between the users, or will Oracle put a userid on them?
    Question 2: I am attempting to enter data into these temp tables within a function that will actually use the data. This function contains and returns a cursor. So far, I have been having great difficulties with this - to the point that I am ready to write an addition function just to store the data in the temp table. Does any one have any suggestions? Here is a sample of my code in case that would help. btw - str2tbl is a home grown conversion tool that parses a string and puts the data into rows of number. We have used it in many functions and so far don't have any issues associated with it.
    in_groupid IN VARCHAR2
    IS
    BEGIN
    INSERT INTO tt_groups(grp_ids)
    VALUES (
    SELECT Column_Value
    FROM THE (
    select cast(STR2TBL(in_groupid) as mytableType)
    from dual
    COMMIT;
    END;
    I am new to the whole sp/function coding, so any advice would be appreciated.
    Thanks,
    Susan

    Thanks, Justin, for your reply.
    I am pleased to hear that the temp table is session-specific.
    I attempted to update my statement to match what you suggested, but I am still getting "invalid" whenever I try to compile the function through schema mgr. Do you see anything that I might be missing? I incorporated the BEGIN; COMMIT; and END;, but is there something else that I am supposed to have? I downloaded a couple of Oracle handbooks and I have one book, Oracle8i - the complete reference, (we are using 9i) that I am referring to all the time, but I can't seem to get it to work! Here is more of my code:
    in_groupid IN VARCHAR2
    RETURN Types.ref_cursor
    AS
         resource_cursor types.ref_cursor;
    BEGIN
         OPEN resource_cursor FOR
    SELECT DISTINCT
    CATEGORY.CATID, SUBCATEGORY.SUBCATID
    FROM SUBCATEGORY, CATSUBCAT, CATEGORY, SUBRES
    WHERE SUBCATEGORY.SUBCATID = CATSUBCAT.SUBCATID AND
    CATSUBCAT.CATID = CATEGORY.CATID AND
    (CATSUBCAT.GROUPID IN (select grp_ids from tt_groups)) AND
    (SUBRES.GROUPID IN (select grp_ids from tt_groups))
    I want to insert this code into the function above:
    INSERT INTO dtra_tt_groups(grp_ids)
    SELECT Column_Value
    FROM THE (
    select cast(STR2TBL(in_groupid) as mytableType)
    from dual
    COMMIT;
    Where would I insert this statement?
    Thanks,
    Susan

  • Temp tables using an interfaces in ci

    what is the purpose of temp tables in ci while performing interfaces
    any one explain me processing

    Processing a CI messes up SQL cursors I recently discovered. A temp table or a rowset to retrieve the values you're looping over (if applicable of course) can help resolve this issue.
    If you mean App Engine processing in general (as in post above), it mostly is to avoid looping per row and doing the same action over and over again, or to avoid having to put a lot of large tables into 1 query (you could update some of the fields in different steps), for instance support I want to update an amount for each person, then I could have a
    In most cases less performant version:
    DoSelect:
    %Select(EMPLID)
    SELECT EMPLID FROM your query
    Followed by:
    INSERT INTO My_Result
    SELECT * FROM My_Table
    Where emplid = %Bind(Emplid)
    In most case better:
    SQL step:
    Insert into %Table(My_ExmplTMP) (EMPLID) SELECT EMPLID FROM your query
    Followed by:
    INSERT INTO My_Result
    SELECT * FROM My_Table Tbl, %Table(My_ExmplTMP) Tmp
    Where Tbl.emplid = TMP.Emplid

  • Insert data from an tabular to a temp table and fetching a columns.

    Hi guys ,
    I am working in apex 3.2 in which in a page i have a data's fom various tables and displays it in tabular form. Then i have to insert the tabular form data to a temp table and fetch the data from the temp table and insert into my main table. I think that i have to use a cursor to fetch the data from the temp table and insert into the main table but i didnt get the perfect example for doing this. Can any one help me to sort it out.
    Thanks With regards
    Balaji

    Hi,
    Follow this scenario.
    Your Query:
    SELECT t1.col1, t1.col2, t2.col1, t2.col2, t3.col1
    FROM table1 t1, table2 t2, table3 t3
    (where some join conditions);On insert button click call this process
    DECLARE
    temp1 VARCHAR2(100);
    temp2 VARCHAR2(100);
    temp3 VARCHAR2(100);
    temp4 VARCHAR2(100);
    temp5 VARCHAR2(100);
    BEGIN
         FOR i IN 1..apex_application.g_f01.COUNT
         LOOP
              temp1    := apex_application.g_f01(i);
              temp2    := apex_application.g_f02(i);
              temp3    := apex_application.g_f03(i);
              temp4    := apex_application.g_f04(i);
              temp5    := apex_application.g_f05(i);
              INSERT INTO table1(col1, col2) VALUES(temp1, temp2);
              INSERT INTO table2(col1, col2) VALUES(temp3, temp4);
              INSERT INTO table3(col1) VALUES(temp5);
         END LOOP;
    END;You don't even need temp tables and cursor to make an insert into different tables.
    Thanks,
    Ramesh P.
    *(If you know you got the correct answer or helpful answer, please mark as corresponding.)*

  • PLSQL script not collecting temp table fields - variables problem?

    I've 'written' a script to extract data from a temp table and load it directly into the associated Oracle tables via HRMS's
    API packages.. but when I put the DBMS_OUTPUT.PUT_LINE's in I see that although it seems to read first API OK it doesn't collect the information from their relevant fields in the temp table.. Can anyone help please please..?
    ======================== code ==========================
    SET serveroutput ON SIZE 1000000
    SET verify OFF
    SET feedback OFF
    DECLARE
    -- Debugging/error handling
    v_err_seq NUMBER := 0;
    v_err_num VARCHAR2 (30);
    v_err_msg VARCHAR2 (250);
    v_err_line VARCHAR2 (350);
    -- Work variables
    p_hire_date DATE;
    p_business_group_id NUMBER := 0;
    p_person_id NUMBER := 0;
    p_address_line1 VARCHAR2 (240);
    p_date_of_birth VARCHAR2 (35);
    p_address_line2 VARCHAR2 (240);
    employee_number VARCHAR2 (14);
    p_employee_number VARCHAR2 (14);
    emp_number VARCHAR2 (14);
    p_email_address VARCHAR2 (240);
    p_address_line3 VARCHAR2 (240);
    p_first_name VARCHAR2 (150);
    p_address_line4 VARCHAR2 (240);
    p_middle_names VARCHAR2 (30);
    p_post_code VARCHAR2 (30);
    p_last_name VARCHAR2 (150);
    p_nationality VARCHAR2 (30);
    p_sex VARCHAR2 (30);
    p_national_identifier VARCHAR2 (30);
    p_title VARCHAR2 (30);
    v_rec_cnt NUMBER := 0;
    insert_flag VARCHAR2 (8);
    -- ip_p_address_id NUMBER;
    ip_p_address_id per_addresses.address_id%TYPE;
    ip_p_object_version_number NUMBER;
    ip_p_party_id per_addresses.party_id%TYPE;
    l_person_id per_all_people_f.person_id%TYPE;
    l_employee_number VARCHAR2 (35);
    l_validate BOOLEAN DEFAULT FALSE;
    l_assignment_id NUMBER;
    l_per_object_version_number NUMBER;
    l_asg_object_version_number NUMBER;
    l_per_effective_start_date DATE;
    l_per_effective_end_date DATE;
    l_full_name VARCHAR2 (240);
    l_per_comment_id NUMBER;
    l_assignment_sequence NUMBER;
    l_assignment_number VARCHAR2 (100);
    l_name_combination_warning BOOLEAN;
    l_assign_payroll_warning BOOLEAN;
    l_address_id NUMBER;
    l_object_version_number NUMBER;
    return_code NUMBER;
    return_message VARCHAR2 (2000);
    command_prin VARCHAR2 (4000);
    -- Get employee details info from work table
    CURSOR get_employee_details
    IS
    SELECT p_person_id, p_validate, p_hire_date, p_business_group_id,
    p_last_name, p_sex, p_date_of_birth, p_email_address,
    p_employee_number, p_first_name, p_marital_status,
    p_middle_names, p_nationality, p_title, p_national_identifier,
    p_address_line1, p_address_line2, p_address_line3,
    p_address_line4, p_post_code
    FROM SU_TEMPLOYEE_DETAILS;
    -- checks employee details info from PER_ALL_PEOPLE_F table
    -- v_err_seq := 1;
    CURSOR c_check_employee (emp_number VARCHAR2)
    IS
    SELECT per.person_id, per.business_group_id, per.last_name,
    per.start_date, per.date_of_birth, per.email_address,
    per.employee_number, per.first_name, per.marital_status,
    per.middle_names, per.nationality, per.national_identifier,
    per.sex, per.title, padd.address_id, padd.primary_flag,
    padd.address_line1, padd.address_line2, padd.address_line3,
    padd.town_or_city, padd.postal_code, padd.telephone_number_1,
    padd.object_version_number
    FROM per_all_people_f per, per_addresses padd
    WHERE per.employee_number = emp_number
    AND per.person_id = padd.person_id;
    emp_rec c_check_employee%ROWTYPE;
    BEGIN
    --v_err_seq := 2;
    command_prin := SQLERRM;
    LOOP
    -- Process each record in the work table
    FOR v_emp IN get_employee_details
    LOOP
    v_rec_cnt := v_rec_cnt + 1;
    -- determine whether customer already exists
    OPEN c_check_employee (v_emp.p_employee_number);
    FETCH c_check_employee
    INTO emp_rec;
    IF c_check_employee%NOTFOUND
    THEN
    insert_flag := 'I';
    ELSE
    insert_flag := 'X';
    END IF;
    IF insert_flag = 'I'
    THEN
    -- RETURN 'Employee does not exist, continue import..';
    DBMS_OUTPUT.PUT_LINE ('Employee does not exist, continue import..');
    ELSE
    DBMS_OUTPUT.PUT_LINE ('Employee found - record cannot be imported.');
    END IF;
    CLOSE c_check_employee;
    -- v_err_seq := 3;
    -- Create new PER_ALL_PEOPLE_F and PER_ADDRESSES record from
    -- info in table record
    IF insert_flag = 'I'
    THEN
    BEGIN -- Importing Employee Procedure --
    DBMS_OUTPUT.PUT_LINE ('          ');
    DBMS_OUTPUT.PUT_LINE ('Importing employees....Hold On.......!     ');
         DBMS_OUTPUT.PUT_LINE ('          ');
    BEGIN
    Hr_Employee_Api.create_gb_employee
    (p_validate => l_validate, --FALSE,
    p_hire_date => p_hire_date,
    p_business_group_id => p_business_group_id,
    p_date_of_birth => p_date_of_birth,
    p_email_address => p_email_address,
    p_first_name => p_first_name,
    p_middle_names => p_middle_names,
    p_last_name => p_last_name,
    p_sex => p_sex,
    p_ni_number => p_national_identifier,
    p_employee_number => l_employee_number,
    p_person_id => l_person_id,
    p_title => p_title,
    p_assignment_id => l_assignment_id,
    p_per_object_version_number => l_per_object_version_number,
    p_asg_object_version_number => l_asg_object_version_number,
    p_per_effective_start_date => l_per_effective_start_date,
    p_per_effective_end_date => l_per_effective_end_date,
    p_full_name => l_full_name,
    p_per_comment_id => l_per_comment_id,
    p_assignment_sequence => l_assignment_sequence,
    p_assignment_number => l_assignment_number,
    p_name_combination_warning => l_name_combination_warning,
    p_assign_payroll_warning => l_assign_payroll_warning
    DBMS_OUTPUT.PUT_LINE
    ('..employee record updated succesfully..');
    DBMS_OUTPUT.PUT_LINE ('          ');
    DBMS_OUTPUT.PUT_LINE ('          ');
    EXCEPTION
    WHEN OTHERS
    THEN
    DBMS_OUTPUT.PUT_LINE ('..SQLCodeErrors:- ' || SQLCODE);
         DBMS_OUTPUT.PUT_LINE (' ');
    DBMS_OUTPUT.PUT_LINE ('Person ID:-' || p_person_id || l_person_id);
    DBMS_OUTPUT.PUT_LINE ('Assignmnt Seq - '|| l_assignment_sequence);
    DBMS_OUTPUT.PUT_LINE ('l_ass_no - ' ||l_assignment_number);
    -- DBMS_OUTPUT.PUT_LINE ('Record failed to load.. ' || SQLERRM);
    DBMS_OUTPUT.PUT_LINE (SUBSTR (command_prin, 1, 250));
    END;
    BEGIN -- Importing Associated Address Procedure --
    DBMS_OUTPUT.PUT_LINE ('          ');
    -- ('..and the associated employee address....');
    Hr_Person_Address_Api.create_person_address
    (p_validate => l_validate,
    -- p_effective_date => p_hire_date,
    p_effective_date => SYSDATE,
    p_pradd_ovlapval_override => NULL,
    p_validate_county => NULL,
    p_person_id => l_person_id,
    p_primary_flag => 'Y',
    p_style => 'GB_GLB',
    -- p_date_from => p_hire_date,
    p_date_from => SYSDATE,
    p_date_to => NULL,
    p_address_type => NULL,
    p_comments => NULL,
    p_address_line1 => p_address_line1,
    p_address_line2 => p_address_line2,
    p_address_line3 => p_address_line3,
    p_town_or_city => p_address_line4,
    p_region_1 => NULL,
    p_region_2 => NULL,
    p_region_3 => NULL,
    p_postal_code => p_post_code,
    p_country => p_nationality,
    p_telephone_number_1 => NULL,
    p_telephone_number_2 => NULL,
    p_telephone_number_3 => NULL,
    p_addr_attribute_category => NULL,
    p_addr_attribute1 => NULL,
    p_addr_attribute2 => NULL,
    p_addr_attribute3 => NULL,
    p_addr_attribute4 => NULL,
    p_addr_attribute5 => NULL,
    p_addr_attribute6 => NULL,
    p_addr_attribute7 => NULL,
    p_addr_attribute8 => NULL,
    p_addr_attribute9 => NULL,
    p_addr_attribute10 => NULL,
    p_addr_attribute11 => NULL,
    p_addr_attribute12 => NULL,
    p_addr_attribute13 => NULL,
    p_addr_attribute14 => NULL,
    p_addr_attribute15 => NULL,
    p_addr_attribute16 => NULL,
    p_addr_attribute17 => NULL,
    p_addr_attribute18 => NULL,
    p_addr_attribute19 => NULL,
    p_addr_attribute20 => NULL,
    p_add_information13 => NULL,
    p_add_information14 => NULL,
    p_add_information15 => NULL,
    p_add_information16 => NULL,
    p_add_information17 => NULL,
    p_add_information18 => NULL,
    p_add_information19 => NULL,
    p_add_information20 => NULL,
    -- p_party_id => NULL,
    p_party_id => ip_p_party_id,
    p_address_id => ip_p_address_id,
    p_object_version_number => ip_p_object_version_number
    DBMS_OUTPUT.PUT_LINE ('Address Updation/Insertion has been successful!');
    EXIT WHEN command_prin IS NULL;
    command_prin := SUBSTR (command_prin, 251);
    END;
    END;
    -- v_err_seq := 4;
    -- End of customer related details
    END IF;
    END LOOP;
    -- DBMS_OUTPUT.PUT_LINE ('Records read : ' || v_rec_cnt);
    -- v_err_seq := 5;
    --EXCEPTION
    -- WHEN OTHERS THEN
    -- ROLLBACK;
    -- Output Error Message
    -- v_err_num := TO_CHAR(SQLCODE);
    -- v_err_msg := SUBSTR(SQLERRM,1,250);
    -- v_err_line := 'Oracle error (seqno=' || v_err_seq || ') ' ||
    -- v_err_num ||' occurred processing record '||
    -- TO_CHAR(v_rec_cnt + 1) ||' : '||v_err_msg;
    -- DBMS_OUTPUT.PUT_LINE(v_err_line);
    END LOOP;
    COMMIT;
    END;
    --END;
    EXIT;
    ======================================================
    many thanks to all...
    Steven

    Ive just sussed it - I had'nt put the 'v_emp' at the front of the fields from the temp table to pick then up! we continue..

Maybe you are looking for

  • Photoshop CS5 trial will not open - "illegal seek" message

    I have Mac OS X 10.7.3 installed. The Adobe Download Assistant is stuck in extracting mode, which I can't seem to get rid of even after deleting the Adobe Download Assistant dmg and reinstalling it. Since I was not able to open the Photoshop CS5 dmg

  • How to create PDF from Publisher A3 landscape file

    I have a poster in an A3 landscape Publisher file, two pages.  When I created a PDF it came out as portrait, and only the left half of each page.  What can I do?  I need to take it to be printed, as I don't have an A3 printer, and the office shop wan

  • Steps in case of imported p.o

    PL.TELL ME STEP BY STEP FOR IMPORTED P.O. WHICH VENDOR iHAVE TO ENTER. THANKS NIRUPAMA

  • Workload Repository Snapshot error

    Hello, Can any one have a better understanding of this error and let me know how to solve this and make it run properly? 1 BEGIN 2 FOR I IN 1..1000000 3 LOOP 4 INSERT INTO T101 VALUES('LARGE STRING'); 5 END LOOP; 6* END; SQL> / BEGIN ERROR at line 1:

  • Table for open POs

    Hi, I need table or transaction which will give me a list of open or partially completed POs in excel format for the perticular plant and materials. thanks in advance