How to declare cursor in procedure based on if condition?

Hi Experts,
In sql server I have eprocedure in which I declare cursor like this:
IF (@int_cntCondition = 1 )
BEGIN
DECLARE Date_Cursor CURSOR FOR select HolidayCcy,HolidayDate from Definition..HolidayCalendar WITH (NOLOCK) where
HolidayCcy in (@Deposit_Currency,@Alternate_Currency)
AND CONVERT(SMALLDATETIME,CONVERT(VARCHAR(25),HolidayDate,106)) >=
CONVERT(SMALLDATETIME,CONVERT(VARCHAR (25),@T_Date,106))
END
ELSE
BEGIN
DECLARE Date_Cursor CURSOR FOR select HolidayCcy,HolidayDate from Definition..HolidayCalendar WITH (NOLOCK) where
HolidayCcy in (@Deposit_Currency,@Alternate_Currency,@Bank_Base_Currency)
AND CONVERT(SMALLDATETIME,CONVERT(VARCHAR(25),HolidayDate,106)) >=
CONVERT(SMALLDATETIME,CONVERT(VARCHAR(25),@T_Date,106))
END
I have to declare same cursor in oracle based on 'if' condition.
But in oracle stored procedur cursor has to declare outside of Begin statment of procedure, so how can I declare This cursor in Orracle?
if anyone know about it, Plese help or send any link to refer.
Thanks.

Digambar wrote:
I have to declare same cursor in oracle based on 'if' condition.The simple answer is to use a reference cursor data type. E.g.
SQL> create or replace procedure GetObjects( cur in out sys_refcursor, objType varchar2 ) is
  2  begin
  3          case
  4                  when upper(objType) = 'EMP' then
  5                          open cur for select * from emp;
  6 
  7                  when upper(objType) = 'DEPT' then
  8                          open cur for select * from dept;
  9 
10          end case;
11  end;
12  /
Procedure created.
SQL>
SQL>
SQL> --// define a host refcursor variable in client
SQL> --// (e.g. VB, .Net, Java, etc)
SQL> var c refcursor
SQL>
SQL> --// make the stored proc call
SQL> begin GetObjects( :c, 'EMP' ); end;
  2  /
PL/SQL procedure successfully completed.
SQL>
SQL> --// process cur reference in client
SQL> print c
     EMPNO ENAME      JOB              MGR HIREDATE                   SAL       COMM     DEPTNO
      7369 SMITH      CLERK           7902 1980/12/17 00:00:00        800                    20
      7499 ALLEN      SALESMAN        7698 1981/02/20 00:00:00       1600        300         30
      7521 WARD       SALESMAN        7698 1981/02/22 00:00:00       1250        500         30
      7566 JONES      MANAGER         7839 1981/04/02 00:00:00       2975                    20
      7654 MARTIN     SALESMAN        7698 1981/09/28 00:00:00       1250       1400         30
      7698 BLAKE      MANAGER         7839 1981/05/01 00:00:00       2850                    30
      7782 CLARK      MANAGER         7839 1981/06/09 00:00:00       2450                    10
      7788 SCOTT      ANALYST         7566 1987/04/19 00:00:00       3000                    20
      7839 KING       PRESIDENT            1981/11/17 00:00:00       5000                    10
      7844 TURNER     SALESMAN        7698 1981/09/08 00:00:00       1500          0         30
      7876 ADAMS      CLERK           7788 1987/05/23 00:00:00       1100                    20
      7900 JAMES      CLERK           7698 1981/12/03 00:00:00        950                    30
      7902 FORD       ANALYST         7566 1981/12/03 00:00:00       3000                    20
      7934 MILLER     CLERK           7782 1982/01/23 00:00:00       1300                    10
14 rows selected.
SQL>
SQL>
SQL> --// make the stored proc call
SQL> begin GetObjects( :c, 'DEPT' ); end;
  2  /
PL/SQL procedure successfully completed.
SQL>
SQL> --// process cur reference in client
SQL> print c
    DEPTNO DNAME          LOC
        10 ACCOUNTING     NEW YORK
        20 RESEARCH       DALLAS
        30 SALES          CHICAGO
        40 OPERATIONS     BOSTON
SQL>

Similar Messages

  • How to configuration of pricing procedure based on the Region

    Hi,
    please help me how to configuration of pricing procedure based on the Region in the roll out project.
    Thanks
    mustafa

    What I proposed to do was,
    a. Create routes like 0 day route, 1 Day route, 2 day route etc.
    b. Route determination is based on the Shipping condition of the customer. Put in the shipping condition for the customer as 00 - immediate delivery. 01 - By Truck, 02 - By Rail, 03 - Ship etc
    c. Now, put in your route determination in such a way that routes change in the sales order with shipping condition (SC). Like, if the shipping condition is set to 00, then 0 day route comes up. Meaning immediate delivery, if SC is 01, then your normal route by truck picks up. etc.
    When the sales order is manually created, you know the time of creation. As route is one of the criteria, the material confirmation happens based on number of days you put in the route to reach the destination. Now that you have the material available for today's delivery, the delivery program can be run to create it, or it can be manually created.
    Now, when you configure the route you have to specify 'Transit duration in calendar days'.
    When you have the sales order created electronically (say thru EDI), then, you may have to ask them to send in shipping condition. Else, you have to modify the function module Idoc_input_orders in such a way that if the sales order creation time is < 12 PM, then put shipping condition as 00, else copy what ever is there in the customer.
    If you do not want to check the time manually when the user creates the sales order, then you may have to use the user exit MV45AFZZ (and I think you can use Save_order_prepare) to check the time and change the shipping condition. By this you will avoid extra coding in Idoc_input_orders and also need not bother if the user changed the route or not.
    Hope my explanation helps.
    Regards,
    Mukund S

  • How to return cursor from procedure to jdbc

    plz help me through example of code as wl as procedure where.... return cursor from procedure to jdbc

    SET QUOTED_IDENTIFIER OFF
    GO
    SET ANSI_NULLS OFF
    GO
    CREATE procedure anil3 @count INT OUT,@opcode INT OUT,@total_tiff INT OUT
    as
    declare @query2 varchar(300),@tiff_count int,@query1 varchar(300)
    set @query1='declare move_cursor   cursor forward_only static for
    select count(opcode),opcode from TABLE1 group by opcode
    open move_cursor'
    exec(@query1)
    fetch next  from move_cursor into @count,@opcode
    set @opcode="'"+@opcode+"'"
    set @total_tiff=0
    while (@@fetch_status=0)
    begin
         set @query2='declare move_cursor2  cursor static for '+
         ' select count(tiff) from TABLE2  where opcode='+@opcode+
           ' open move_cursor2 '
         exec(@query2)
         fetch next  from move_cursor2 into @tiff_count
         while (@@fetch_status=0)
         begin
              set @total_tiff=@total_tiff+@tiff_count
              fetch next  from move_cursor2 into @tiff_count
         end
         close move_cursor2
         deallocate move_cursor2
    print  @total_tiff
    print @count
    print @opcode
    fetch next  from move_cursor into @count,@opcode
    end
    close move_cursor
    deallocate move_cursor
    SET QUOTED_IDENTIFIER OFF
    GO
    SET ANSI_NULLS ON
    GO******************************************************************************
    above this is sql server 2000 PL/SQL and i hv to get the value
    print @total_tiff
    print @count
    print @opcode
    through JDBC
    plz help me out how to return Cursor to JDBC and HOW toPRINT THESE THREE VALUE @total_tiff, @count, @opcode through JDBC
    get this values through JDBC

  • How to declare cursors dynamically

    I am writing a trigger.
    in the body of the trigger, I need to make a select query on a table like
    select column1 from tablename where order_id = some_variable_name...
    for each of the column1, I need to do some operation. Problem is I get the value of some_variable_name only in the body of the trigger, so I cant declare a cusor for this select in the declare section.
    Is there any way to declare this cursor in the body block of the trigger, or is there some other way to make a select query and store the results in some data structure?

    One can still declare the cursor in the declare section of the trigger ... just need to parameterize the cursor definition:
    create or replace trigger bit
    before insert on t
    for each row
    declare
      cursor crsdef(av_nm usr.nm%type) is
      select count(0) cnt
      from   usr
      where  nm = initcap(av_nm);
    begin
      for crs in crsdef(:new.nm)
      loop
        dbms_output.put_line('cnt for '||:new.nm||' is: '||crs.cnt);
      end loop;
    end;
    /Better yet, put the whole thing (cursor and all) in a stored procedure/function and call that from the trigger.

  • How to secure access of Report based on a condition

    Hello Experts,
    My project requirement is to secure BW Reports based on a condition. For e.g a user should be authorized to access the Report if:
    1. He is the WBS Manager of the selected WBS Element
    OR
    2. If he is authorized to access the Profit center Hierarchy Node which is the parent of the selected WBS Element.
    I think this may be achieved by using a Customer exit in the Analysis authorization but i don't know how.
    Do you have any idea, whether it is possible to achieve in BI7 Security Model? Any help will be highly appreciated.
    Thanks
    Rajat

    Hi Tomer,
    There will be a selection variable for WBS in all BW reports. If the user selects a particular WBS Element then he can only see the result of the report if he fulfill EITHER of the following conditions:
    1. If he is the WBS Manager of the selected WBS Element
    OR
    2. If he is authorized to access the Profit center Hierarchy Node which is the parent of the selected WBS Element.
    WBS managers will keep on changing so it is not possible to maintain the users in one role.
    Secondly, according to the second condition, even if the user is not WBS Manager but he is authorized to access Profit center Hierarchy Node, which is the parent of the selected WBS Element, he should view the report.
    Please let me know if don't understand the question.
    Thanks
    Rajat

  • How to make a region mandatory based on some conditions using CO Extension?

    Dear All,
    I want to make Attachments region in a seeded page mandatory, based on some conditions. I am able to make fields mandatory using CO Extension, but i am not able to make the attachments region mandatory. Please help.
    Thanks
    Raj

    Raj,
    I have not tried but check if you could get the rowcount which shows how many attachment are upload or not. Then by checking this throw exception if the rowcount is o.
    Thanks
    --Anil
    http://oracleanil.blogspot.com/

  • How to change users' initial page based on a condition

    I'm using SSO on my application, and have two types of users who will be logging on - I want one set (admins) to go straight to one page, and the other set (users) to go to a another page after logging in. These two sets of users are stored in the database, so I can want to use that to check against.
    I get the impression this would be easy enough if my users went via the 101-login page, but as I'm using SSO I don't think they do. I can change the default starting page, with the home link setting in the application's security attributes, but you can only set one of those.
    I don't mind having it all default to one page, and then redirect away from that if the username meets a particular condition, but can't see how I can do that.
    Can anyone suggest how I can work this to achieve what I need?

    Tim,
    First I would create a HOME_PAGE application item. Then I would create an application computation on new instance that sets that item accordingly. something like this:
    with user_table as(
        select 'TIM' user_name, 'ADMIN' user_role from dual
    select case
               when exists(select *
                             from user_table
                            where user_name = :APP_USER
                              and user_role = 'ADMIN')
               then
                  102
               else
                  103
          end
      from user_tableI would make a landing page all people go to. Page 150. On that page i would make a branch before header which references your HOME_PAGE application item.
    Cheers,
    Tyson Jouglet

  • How do i hide a tablix based on 3 conditions

    I have a tablix that I need to set the visibility to hide if  the following any of the following conditions are true
    1 Field accountName = TESTAccount
    2 Field InvoiceType = 1
    3 Field TFiles = 0
    Dont ask me .. i dont know

    Hi Pete,
    Per my understanding that you want to hide an tablix based on three different values from three different columns, right?
    Could you please help to provide more details information to help us more effective to provide an solution:
    If the three values of the three columns are in the same number of rows of in different row or the tablix just have one row?
    Did the three fields in the tablix you want to conditional hide or in a different Tablix
    It is better you give us some snapshot of the report in both design and preview mode and some sample data.
    Please find the details information below about some possible situation i assumed:
    You can modify the query to get the rownumber to add in the report, then use expression as below:
    =IIF(
    MAX(IIF(Fields!ROWNUMBER.Value =1,Fields!AccountName.Value,Nothing))="TESTAccount"
    or MAX(IIF(Fields!ROWNUMBER.Value =2,Fields!InvoiceType.Value,Nothing))=1
    or  MAX(IIF(Fields!ROWNUMBER.Value =3,Fields!TFiles.Value,Nothing))=0 ,true,false)
    If the three values in different columns and different rows, you can create three hide parameters (AccountName,InvoiceType,TFiles)for each fields and find the correct index (begin with 0)to put in the parameter to get the correct value(TESTAccount,1,0):
    for example:
    Parameters!AccountName.Value(0)="TESTAccount"
    Parameters!InvoiceType.Value(1)=1
    Parameters!TFiles.Value(2)=0
    Using below expression to hide the tablix:
    =IIF(Parameters!AccountName.Value(0)="TESTAccount" or Parameters!InvoiceType.Value(1)=1 or Parameters!TFiles.Value(2)=0, true, false)
    Note: make sure the order of the value in the parameter dropdown list is the same as that in the report.
    If the three values are in the same row of different column, you can reference to similar thread below:
    Change Column Header / Column Background
    color based on a value in a specific row in the same column
    You can use the expression:
    =IIF(First(Fields!AccountName.Value, "DataSet2")="TESTAccount" or First(Fields!InvoiceType.Value, "DataSet2")=1 or First(Fields!TFiles.Value, "DataSet2")=0, true, false)
    If you still have any problem, please feel free to ask.
    Regards
    Vicky Liu
    Vicky Liu
    TechNet Community Support

  • "How do you build a filter based on the conditions of two columns?"

    Hi all,
    line desc     Period     Amount1     Amount2
    jan feb 0 10
    jan mar 0 20
    jan jan 0 30
    jan apr 0 40
    I have a report like this with four columns
    Line Descr is from one table and period from other table and amounts 1 and amounts 2 are respective amounts.
    now i need to see the only one column in the Result i,e. jan jan 0 30
    I need to write a sql in the column formula so that i need to get this Result
    Any suggestions like what sql do i need to write
    thanks
    Xavier.
    Edited by: Xavier on Jul 1, 2011 12:03 PM
    Edited by: Xavier on Jul 1, 2011 12:04 PM
    Edited by: Xavier on Jul 1, 2011 12:05 PM
    Edited by: Xavier on Jul 1, 2011 12:05 PM
    Edited by: Xavier on Jul 1, 2011 12:06 PM
    Edited by: Xavier on Jul 1, 2011 12:07 PM
    Edited by: Xavier on Jul 2, 2011 11:37 AM

    David,
    Thank you very much for your Reply.I was looking,who could understand my situation and guess "YOU DID'
    I'll tell my situation David.
    We used to have a sql filter for this Report .In 11.1.1.3 version it used to work ,but in 11.1.1.5 we have a bug .if you have a sql filter in the Report it is not allowing us to use navigation links on that report it is saying some "Assertion Error".
    We are using this Report on Dashboard .If we use the report on Dashboard and if that Report contains the Sql Filter than it's throwing the "ASSERTION ERROR".
    but if i open the same Report from the catalog then the navigation links works fine
    Can you help me out with this one .
    Thanks
    Xavier

  • How to find pricing procedure based on condition type

    Hi,
    Please tell me any one " how to find the pricing procedure based on condition type " is there any tables.
    Thanks

    check table - T683S, where you get all prciing procedures for which has same condition type.
    go to se16
    give table - T683S
    in condition type feild, menation your condition type and execute, you get all procedures with condition type.

  • How to retrieve the max value from a cursor in procedure

    Hi,
    In a procedure, I defined a cursor:
    cursor c_emp is select empno, ename, salary from emp where ename like 'J%';
    but in the body part, I need to retrieve the max(salary) from the cursor.
    could you please tell me how I can get the max value from the cursor in the procedure.
    Thanks,
    Paul

    Here is one sample but you should just get the max directly. Using bulk processing should be a last resort.
    DECLARE
      CURSOR c1 IS (SELECT * FROM emp where sal is not null);
      TYPE typ_tbl IS TABLE OF c1%rowtype;
      v typ_tbl;
      max_sal number;
    BEGIN
      OPEN c1;
      max_sal := -9999999999999;
      LOOP                                                 --Loop added
        FETCH c1 BULK COLLECT INTO v LIMIT 3; -- process 3 records at a time
            -- process the records
           DBMS_OUTPUT.PUT_LINE('Processing ' || v.COUNT || ' records.');
            FOR i IN v.first..v.last LOOP
                 if v(i).sal > max_sal then
                   max_sal := v(i).sal;
                 end if;
                DBMS_OUTPUT.PUT_LINE(v(i).empno);
            END LOOP; 
        EXIT WHEN c1%NOTFOUND;
      END LOOP;
      DBMS_OUTPUT.PUT_LINE('Max salary was: ' || max_sal);
    END;
    Processing 3 records.
    7369
    7499
    7521
    Processing 3 records.
    7566
    7654
    7698
    Processing 3 records.
    7782
    7788
    7839
    Processing 3 records.
    7844
    7876
    7900
    Processing 2 records.
    7902
    7934
    Max salary was: 5000

  • How get a cursor from a store procedure

    i have a package with a procedure like this
    PACKAGE PKG_TEST IS
    TYPE data_cursor IS REF CURSOR;
    PROCEDURE PRC_GET_DATA( VAR_ONE IN VARCHAR2, IO_CURSOR OUT data_cursor ) ;
    END ;
    PACKAGE BODY PKG_TEST IS
    PROCEDURE PRC_GET_DATA( VAR_ONE IN VARCHAR2, IO_CURSOR     OUT data_cursor ) IS
    MENSAJE VARCHAR2(1000);
    CURSOR_AUX DATA_CURSOR;
    ERR_NUM NUMBER;
    ERR_MSG VARCHAR2(100);
    BEGIN
         OPEN CURSOR_AUX FOR
         SELECT ATTRIB1, ATRIB2 FROM TABLE WHERE (CODITION);
    IO_CURSOR := CURSOR_AUX;
    END PRC_GET_DATA;
    END;
    and, i have some troubles to call from JSP page...
    the java Source is
    Connection conn = source.getConnection();
    Statment stmt = conn.createStatment();
    CallableStatment cs = conn.prepareCall( {CALL PKG_TEST.PRC_GET_DATA( '%') } );
    ResultSet rset = cs.executeQuery();
    Some can help me?....

    I would not know about JAVA call Syntax to Oracle procedure in the code you are showing, Also it is not
    the right place for that question. How ever, I can see that your PL/SQL code needs some fixing
    before it can compile and run, hence some simple demonstrationSQL> create or replace package test_pkg as
      2  TYPE data_cursor IS REF CURSOR;
      3  PROCEDURE PRC_GET_DATA( VAR_ONE IN VARCHAR2, IO_CURSOR OUT data_cursor);
      4  END;
      5  /
    Package created.
    -- Please note that you need to put your SQL for ref cursors in single quotes
    -- Also look at the passing the WHERE condition to the SQL
    SQL> create or replace package body test_pkg as
      2  PROCEDURE PRC_GET_DATA(VAR_ONE IN VARCHAR2, IO_CURSOR OUT data_cursor) IS
      3    l_cursor data_cursor;
      4  BEGIN
      5    OPEN l_cursor for ('SELECT empno, ename from my_emp WHERE '|| VAR_ONE);
      6    IO_CURSOR := l_cursor;
      7  END;
      8  END;
      9  /
    Package body created.
    -- Then simply use the returned REF CURSOR in any program, I am showing PL/SQL program here
    SQL> Declare
      2     myCur test_pkg.data_cursor;
      3     vEmpNum Number;
      4     vEname  Varchar2(20);
      5  Begin
      6     test_pkg.PRC_GET_DATA('Sal > 1000', myCur);
      7     Loop
      8       Fetch myCur into vEmpNum, vEname;
      9       Exit When myCur%NOTFOUND;
    10       dbms_output.put_line(vEmpNum || '  ' || vEname);
    11     End Loop;
    12     Close myCur;
    13  End;
    14  /
    7369  SMITH
    7499  ALLEN
    7521  WARD
    7566  JONES
    7654  MARTIN
    PL/SQL procedure successfully completed.Might not be exactly what you are looking for, but from Oracle Forum, this is what is relevant.
    Good luck,
    Sri

  • How to pass multiple parameters while calling a pl/sql procedure based serv

    Hi,
    I have a pl/sql procedure based service that needs to be invoked from the bpel console for testing purpose. This procedure accepts multiple input values which are of varchar2,boolean and datetime data types. How can I get the bpel console to throw a UI where I can enter these values --in other words where(which file and where) can I specify that these are the input parameters that need to be entered along with their types.
    Thanks for yr help!

    Change the payload of the request 'Process WSDL' message type. Change the element of the payload for the RequestMessage to be 'InputParameters' from the XSD generated by the DB Adapter wizard.
    Edit the payload (Element) - Choose 'Project Schema Files'. Select 'InputParameters' from the XSD.
    You can also change the ResponseMessage by doing the same thing, except that you select 'OutputParameters' from the XSD.

  • Command for "How to find Cursor Size" in Oracle Stored Procedure"

    Hi
    Can u tell me....
    How to find Cursor Size" in Oracle Stored Procedure........
    I want command for that........

    why don't you try select count(*) from your_table;That requires running the same query twice - or rather running two different queries twice. Besides it still doesn't guarantee anything, because Oracle's read consistency model only applies at the statement level (unless you're running in a serialized transaction).
    This is such a common requirement - users are wont to say "well Google does it" - it seems bizarre that Oracle cannot do it. The truth is that that Google cheats. Firstly it guesses the number on the basis of information in its indexes and refines the estimate as pages are returned. Secondly, Google is under no onus to kepp all its data and indexes synchronized - two simultaneous and identical queries which touch different Google servers can return different results. Oracle Text works the same way, which is why we can get a count with CTX_QUERY.COUNT_HITS in estimate mode.
    Cheers, APC
    blog: http://radiofreetooting.blogspot.com
    .

  • How return parameter ref Cursor from procedure using dynamic SQL?

    I sorry, but i very need help.
    I using Oracle 8.0.6
    I need to return parameter of type ref Cursor from procedure.
    create or replace package PlanExp is
    type cursortype is ref cursor;
    procedure ShowPlan (cursorparam out
    cursortype.............);
    end PlanExp;
    create or replace package body PlanExp is
    procedure ShowPlan (cursorparam out cursortype,
    .............) Is
    sql_str varchar2(1000);
    sql_str_select varchar2(100);
    sql_str_from varchar2(100);
    sql_str_where varchar2(500);
    Return_Code integer;
    Num_Rows integer;
    cur_id_sel integer;
    tSum_Plan DBMS_SQL.NUMBER_TABLE;
    tSum_Plan_Ch DBMS_SQL.NUMBER_TABLE;
    tSum_Plan_Day DBMS_SQL.NUMBER_TABLE;
    begin
    /* calculating string variables ........... /*
    sql_str := 'select ' || sql_str_select ||
    'from ' || sql_str_from ||
    'where ' || sql_str_where ||
    'group by ' || sql_str_select;
    cur_id_sel := dbms_sql.open_cursor;
    dbms_sql.parse(cur_id_sel, sql_str, dbms_sql.native);
    dbms_sql.define_array(cur_id_sel, 1, tSum_Plan, 20, 1);
    dbms_sql.define_array(cur_id_sel, 2, tSum_Plan_Ch, 20, 1);
    dbms_sql.define_array(cur_id_sel, 3, tSum_Plan_Day, 20, 1);
    Return_Code := dbms_sql.execute(cur_id_sel);
    delete from TEMP_SHOWPLAN;
    Loop
    Num_Rows := dbms_sql.Fetch_Rows(cur_id_sel);
    dbms_sql.column_value(cur_id_sel, 1, tSum_Plan);
    dbms_sql.column_value(cur_id_sel, 2, tSum_Plan_Ch);
    dbms_sql.column_value(cur_id_sel, 3, tSum_Plan_Day);
    if Num_Rows = 0 then
    exit;
    end if;
    Exit When Num_Rows < 20;
    End Loop;
    dbms_sql.close_cursor(cur_id_sel);
    end;
    end PlanExp;
    How return cursor (cursorparam) from 3 dbms_sql.column_value-s ?

    I am using Oracle 8.1.7, so I don't know if this will work in
    8.0.6 or not:
    SQL> CREATE TABLE test
      2    (col1                    NUMBER,
      3     col2                    NUMBER,
      4     col3                    NUMBER)
      5  /
    Table created.
    SQL> INSERT INTO test
      2  VALUES (1,1,1)
      3  /
    1 row created.
    SQL> INSERT INTO test
      2  VALUES (2,2,2)
      3  /
    1 row created.
    SQL> INSERT INTO test
      2  VALUES (3,3,3)
      3  /
    1 row created.
    SQL> CREATE TABLE temp_showplan
      2    (tSum_Plan               NUMBER,
      3     tSum_Plan_Ch            NUMBER,
      4     tSum_Plan_Day           NUMBER)
      5  /
    Table created.
    SQL> EDIT planexp
    CREATE OR REPLACE PACKAGE PlanExp
    IS
      TYPE CursorType IS REF CURSOR;
      PROCEDURE ShowPlan
        (cursorparam    IN OUT CursorType,
         sql_str_select IN     VARCHAR2,
         sql_str_from   IN     VARCHAR2,
         sql_str_where  IN     VARCHAR2);
    END PlanExp;
    CREATE OR REPLACE PACKAGE BODY PlanExp
    IS
      PROCEDURE ShowPlan
        (cursorparam    IN OUT CursorType,
         sql_str_select IN     VARCHAR2,
         sql_str_from   IN     VARCHAR2,
         sql_str_where  IN     VARCHAR2)
      IS
        sql_str                VARCHAR2 (1000);
        cur_id_sel             INTEGER;
        return_code            INTEGER;
      BEGIN
        DELETE FROM temp_showplan;
        sql_str := 'INSERT INTO   temp_showplan '
               || ' SELECT '   || sql_str_select
               || ' FROM '     || sql_str_from
               || ' WHERE '    || sql_str_where;
        cur_id_sel := DBMS_SQL.OPEN_CURSOR;
        DBMS_SQL.PARSE (cur_id_sel, sql_str, DBMS_SQL.NATIVE);
        return_code := DBMS_SQL.EXECUTE (cur_id_sel);
        DBMS_SQL.CLOSE_CURSOR (cur_id_sel);
        OPEN cursorparam FOR SELECT * FROM temp_showplan;
      END ShowPlan;
    END PlanExp;
    SQL> START planexp
    Package created.
    Package body created.
    SQL> VARIABLE g_ref REFCURSOR
    SQL> EXEC PlanExp.ShowPlan (:g_ref, 'col1, col2,
    col3', 'test', ' 1 = 1 ')
    PL/SQL procedure successfully completed.
    SQL> PRINT g_ref
    TSUM_PLAN TSUM_PLAN_CH TSUM_PLAN_DAY
             1            1             1
             2            2             2
             3            3             3

Maybe you are looking for

  • Production Order and Internal Order for each item of the sales order

    Hi    I am developing Make To Order Report where I have to display the MTO Line Items and non MTO Line Items. For non MTO Line Items I have to display Internal order with Planned and Actual Costs and also Production Order with Planned and Actual Cost

  • Report writing for Web Access

    Is there any good guides that people know of for writing reports in P6 v6.1? I'm trying to integrate them into the P6 Web Access and not having much joy, but a bit better knowledge of how to build them originally might just help too. MTIA David

  • Change default query display settings (show more cells)

    Hello Friends! I have a little issue with default display settings in the Bex Query Designer. Can I change the display settings like in an analyses item e.g. more Number of Data Columns Displayed at once? Thank you for your help Best regards Florian

  • Multiple idoc segments from single flat file

    hi, I want to upload data throught LSMW,   in a single row i have many item. can anyone give me idea, how to proceed. 2.  i have to show a custom error report linked to lsmw.. how to do it.. waiting for your reply Thanks & Regards Dinesh

  • Can you shuffle songs on a playlist?

    Is it possible to shuffle songs on a playlist? Is so, how? I have a 60gb, 5th gen. Thanks