Is IN OUT for Cursor variable mandatory?

Hi all:
I have a stored procedure which will just return a boolean value after the task is done. And i'm using more than 1 cursor variables in that stored procedure. What my question is
"Is IN OUT for Cursor variable mandatory from the PROCEDURE i have written?".
Because in the manual they mentioned that IN OUT should be there for a cursor variable. My PROCEDURE declaration is as below:
TYPE emp_det IS REF CURSOR;
PROCEDURE <proc_name>(startdate VARCHAR2, enddate VARCHAR2, ids VARCHAR2, taskdone OUT BOOLEAN,emp IN OUT emp_det);
Is there any modification in the above declaration if i'm using one cursor and NOT returning that cursor back to the called program. I don't to get returned.
Hope i made it clear.
Thanks,
- Venu

Venu:
As far as I know you don't need In Out unless
you are using that variable to pass values between the two procedures.
It is so easy to try it , so I suggest you write two small procedures to check this.It should only take a couple of minutes.
Hope this helps.

Similar Messages

  • How to pass a litral string into cursor variable?

    Hi All
    I have a code like below:
    I need to select the following table,column with the criteria as such but it looks like the literal string does not work for cursor variable.
    I can run the SQL in sqlplus but how I can embed that in PL/SQL code??
    -Thanks so much for the help
    cursor ccol2(Y1 varchar2) is select table_name,column_name from user_tab_columns
    where table_name like 'HPP2TT%' and table_name like '%Y1'
    and column_name not in ('MEMBERID');

    Literal strings are fine in a cursor, however, your logic is likely wrong, and you are not using the Y1 parameter to the cursor correctly. If you are looking for tables that either start with HPP2TT or end with Y1 (whatever you pass as Y1), then you need something more like:
    cursor ccol2(Y1 varchar2) is
    select table_name, column_name
    from user_tab_columns
    where (table_name like 'HPP2TT%' or
           table_name like '%'||Y1) and
          column_name not in ('MEMBERID');In the unlikely event that you are lookig for table that actually do start with HPP2TT and end in whatever is passed in Y1 then your query could be simplified to:
    cursor ccol2(Y1 varchar2) is
    select table_name, column_name
    from user_tab_columns
    where table_name like 'HPP2TT%'||Y1 and
          column_name not in ('MEMBERID');Note in both cases, a single member in-list is bad practice, although Oracle will transform it to an equality predicate instead.
    John

  • Error -90032 occurred at Error in function centref at line 5 column 8: The indexes are out of bounds for the variable you specified

    Sir, 
    i am running a matlab code in mathscript of labview but getting an error
    Error -90032 occurred at Error in function centref at line 5 column 8:  The indexes are out of bounds for the variable you specified
    this code running successfully in matlab 
    please help me in this regard
    a .vi format file is attached named as mfcc_new.vi
    Attachments:
    mfcc2.vi ‏35 KB
    mfcc_new.vi ‏111 KB

    May I see you have 6 inputs to your Mathscript Node. When you test it in Matlab I suposse that you're using some values for this inputs and everything work as expected. Then, run it in Labview using highlight execution, retaining wire values and using single stepping. Check the values which are being inserted to your Mathscript Node and ensure that they are correct. You're having an "indexes out of bounds" mistake, so it probably means that there is something  wrong with the inputs according to your expectations. You can also put the MathScript alone in another VI and insert the inputs you're expecting manually and check in the same way.
    Good luck!

  • Cursor variable and for update

    hi
    can anyone explain me why can't we use "for update " with a Cursor Variable.
    Thanks in advance.

    user10314274 wrote:
    exmple : I read it in one book(Oracle press)And how difficult is it to test this?
    declare
        v_cur sys_refcursor;
        v_ename varchar2(20);
    begin
        open v_cur for select ename from emp for update;
        loop
          fetch v_cur into v_ename;
          exit when v_cur%notfound;
          dbms_output.put_line(v_ename);
        end loop;
        close v_cur;
        dbms_output.put_line('----------------------');
        open v_cur for 'select ename from emp for update';
        loop
          fetch v_cur into v_ename;
          exit when v_cur%notfound;
          dbms_output.put_line(v_ename);
        end loop;
        close v_cur;
    end;
    SMITH
    ALLEN
    WARD
    JONES
    MARTIN
    BLAKE
    CLARK
    SCOTT
    KING
    TURNER
    ADAMS
    JAMES
    FORD
    MILLER
    SMITH
    ALLEN
    WARD
    JONES
    MARTIN
    BLAKE
    CLARK
    SCOTT
    KING
    TURNER
    ADAMS
    JAMES
    FORD
    MILLER
    PL/SQL procedure successfully completed.
    SQL> SY.

  • PL/SQL package hasc1 in out cursor variable param.how to exec @ SQL

    I have a PL/SQL procedure with 1 in out parameter which is cursor variable. How to execute this procedure on SQL prompt?
    My code looks like this:
    CREATE OR REPLACE PACKAGE PackFlight AS
         TYPE GenCurType is REF CURSOR;
         PROCEDURE searchFlight(pdate in flight.flight_date%TYPE,
                             gen_cursor IN OUT GenCurType);
    END PackFlight;
    I want to execute this procedure at SQL Prompt? Could you please tell me how to do this?
    If I create a stand-alone procedure with ref-cursor, then how to execute this @ SQL Prompt?
    Thanks a lot,
    Supriya

    var rc refcursor
    exec packflight.searchflight (sysdate, :rc);

  • How to Execute  sql query in PL/SQL ( a variable) with out using Cursor or REF cursor

    Hi
    I am building a dynamic query based on some conditions
    as an example
    v_query varchar2(2000);
    x1 varchar2(20);
    y1 varchar2(20);
    z1 varchar2(20);
    v_query := ' Select x,y,z into x1,y1,z1 From ... ';
    Is there any way to execute the query with out using cursor or ref cursor..
    Thanks
    Arun

    Both Tod and Eric provided valid responses given the format of the queory you supplied. Howver, if you want to use dynamic sql in either way, you need to be absolutely certain that your query will always only return a single row (e.g. SELECT COUNT(*) FROM mytable), because if it retuns more than one, your procedure will break unless you have an exception handler to handle either TOO_MANY_ROWS or OTHERS.
    If you want to pull in a lot of data without walking a cursor, you should look at the BULK COLLECT options.

  • Cursor Variables in Pro*C/C++

    I have very strange behaivour of the client application that uses cursor variable.
    I have Oracle 8i enterprise 8.1.6 release for Sun/Solaris.
    The follow SQL is installed on server:
    create or replace package dummy is
    type vemap_cur is ref cursor;
    end;
    create or replace procedure GET_CUR
    ( N IN number, cur IN OUT dummy.VEMAP_CUR ) as
    begin
    open cur for
    select LS.ID, LS.SCALE
    from LAYERS LS
    where LS.ID = (select C.ID from CTM C where C.ORDERINDEX = N);
    end;
    This procedure (GET_CUR) i call from embedded SQL in follow manner:
    EXEC SQL BEGIN DECLARE SECTION;
    struct
    int n1;
    int n2;
    } resrec;
    sql_cursor c1;
    int num;
    EXEC SQL END DECLARE SECTION;
    EXEC SQL ALLOCATE :c1;
    EXEC SQL AT DB_VE EXECUTE
    BEGIN
    GET_VEC( :num, :c1 );
    END;
    END-EXEC;
    Till now it is Ok. But when i run the follow line
    EXEC SQL FETCH :c1 INTO :resrec;
    i accept ORA-01012: not logged on
    error !!!!
    I checked the connection via using cursor in paralell and got the correct answer.
    Therefore i think this error is not related to the actual problem and i have no idea what this problem is. I tried to open cursor via anonymous PL/SQL block inside my C program with same result.
    Need help ASAP.
    Leonid
    null

    Hi Leonid, Andrea
    When you use "CONNECT AT :db_handle" instead of default connection "CONNECT", you have to give the connect handle to the command you want to execute.
    ie:
    EXEC SQL AT :db_handle PREPARE SQL_stat FROM "select ...";
    EXEC SQL AT :db_handle DECLARE cur_stat CURSOR for SQL_stat;
    EXEC SQL AT :db_handle OPEN cur_stat ;
    EXEC SQL AT :db_handle FETCH cur_stat INTO :resrec;
    Leonid, the error you had is probably because you connected at "DB_VE", and tried to select from default connect (that you're not connected to ==> ORA-01012)
    Try EXEC SQL AT :DB_VE FETCH :c1 INTO :resrec;
    or, if you connect to only 1 database, use "EXEC SQL CONNECT;" instead of (EXEC SQL CONNECT :pConnectString AT "DB_VE";) so that you use default connect name and you don't have to add "AT :DB_VE" to your SQL commands.
    I know this reply comes long after your request, but I hope it may still help anybody.

  • How to (in Pro*C) pass a cursor variable as a pointer between functions

    I am opening a cursor in a called function that accepts as one argument a pointer to a cursor variable, and a second argument for the sql string defining the cursor select. That works fine, and in that same function can successfully fetch and access the records from the cursor. However, my objective is to fetch the records in another function that calls the first function. I want to pass back to the calling function the pointer to the cursor variable from the first function. In the second (calling) function, is where I want to fetch the records. What I am getting is SQLCODE = -1002 (fetch out of sequence).
    Here is the relevent code in the first called function that calls a PL/SQL package procedure to open the cursor, followed by the code in the second calling procedure where I am attempting to fetch the records:
    /******Called function code starts here ******/
    EXEC SQL INCLUDE SQLCA;
    long db_makeCursor(cursorID, SQLstr)
    EXEC SQL BEGIN DECLARE SECTION;
    sql_cursor cursorID;      / a pointer to a cursor variable */
    char *SQLstr;
    EXEC SQL END DECLARE SECTION;
    long SQLCODE;
    EXEC SQL BEGIN DECLARE SECTION;
    sql_cursor dbCursor; /* a cursor variable */
    EXEC SQL END DECLARE SECTION;
    EXEC SQL WHENEVER SQLERROR DO sql_error();
    dbCursor = *cursorID;
    EXEC SQL EXECUTE
    BEGIN
    db_util_ref_cursor_pkg.open_dbNameCursor( :dbCursor, :SQLstr );
    END;
    END-EXEC;
    return;
    /******Calling function code starts here ******/
    EXEC SQL INCLUDE SQLCA;
    EXEC SQL BEGIN DECLARE SECTION;
    static PROCLOG PROC_Rec;
    EXEC SQL END DECLARE SECTION;
    long retrieveProcesses( _proclog, sqlForProcLog )
    EXEC SQL BEGIN DECLARE SECTION;
    PROCLOG _proclog;
    char *sqlForProcLog
    EXEC SQL END DECLARE SECTION;
    long rc;
    long SQLCODE;
    EXEC SQL BEGIN DECLARE SECTION;
    sql_cursor dbCursor; /* a cursor variable */
    sql_cursor cursorID;      / a pointer to a cursor variable */
    PROCLOG proclog;
    short end_ts_ind;
    short proc_name_ind;
    short comments_ind;
    EXEC SQL END DECLARE SECTION;
    cursorID = &dbCursorName; /* assign a value to the pointer */
    EXEC SQL ALLOCATE :dbCursor;
    rc = dbUtilities_makeCursor( cursorID, sqlForProcLog);
    if (rc == TRUE)
    while (SQLCODE == 0)
    EXEC SQL FETCH :dbCursorName INTO
    :proclog.PROC_ID,
    :proclog.START_TS,
    :proclog.END_TS:end_ts_ind,
    :proclog.PROC_NAME:proc_name_ind,
    :proclog.COMMENTS:comments_ind,
    if (SQLCODE == 0)
    printf("PROC_ID: %d; COMMENTS: %s\n",proclog.PROC_ID, proclog.COMMENTS);
    } /* end retrieveProcesses */

    You need to include a loop...
    for i=0;i<sqlca.sqlerrd[2];i++)
    printf("name %s\n", struct.name)
    This allows you to step through your cursor records!!!

  • Cannot enter value in selection screen for Hierarchy variable.

    Hi All,
    I have a hierarchy variable on the selection screen for Org unit.
    When i execute the report via Bex or RSRT i am able to enter the value directly into the selection screen input field without going for F4 help and then selecting the value.
    But when the same query is used in web template and executed the input field for the variable on the selection screen is greyed out and doesnt allow to type in the value. Only way to fill in the value is via F4 help.
    Can anyone tell why is this happening and is there any way this can be changed?
    Thanks in advance.
    -RJ

    Hi Prakash,
    I am not able to select or click on the input field of the selection screen before and after selecting the value
    CTRL+K doesnt work for me.
    The display field is populated only when i select a node from the F4 help screen.
    When executed from RSRT the field is highlighted and i am able to enter the value unlike when executed on web browser.
    The variable is Mandatory multiple single value readu for input.
    I found an article saying that for hierarchy node variables the values are forced by F4 value help as the values that are entered manually might not be unique.
    This is the link
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/15839190-0201-0010-adb1-d2edd9857b0a
    I would like to know if there is a work around or setting that can be made to make it work?
    -RJ

  • Fetch from cursor variable

    Hello,
    I have a procedure, which specification is something like that:
    procedure proc1 (pcursor OUT SYS_REFCURSOR, parg1 IN NUMBER, parg2 IN NUMBER, ...);Inside the body of proc1 I have
    OPEN pcursor FOR
      SELECT column1,
                  column2,
                  CURSOR (SELECT column1, column2
                                    FROM table2
                                  WHERE <some clauses come here>) icursor1
          FROM table1
       WHERE <some clauses come here>;In a PL/SQL block I would like to execute proc1 and then to fetch from pcursor. This is what I am doing so far:
    DECLARE
      ldata SYS_REFCURSOR;
      larg1 NUMBER := 123;
      larg2 NUMBER := 456;
      outcolumn1 dbms_sql.Number_Table;
      outcolumn2 dbms_sql.Number_Table;
    BEGIN
      some_package_name.proc1 (ldata, larg1, larg2, ...);
      FETCH ldata BULK COLLECT INTO
        outcolumn1, outcolumn2,...,  *and here is my problem*;
    END;
    /How can I rewrite this in order to get the content of icursor1 ?
    Thanks a lot!

    Verdi wrote:
    How can I rewrite this in order to get the content of icursor1 ?
    Firstly ref cursors contain no data they are not result sets but pointers to compiled SQL statements.
    Re: OPEN cursor for large query
    PL/SQL 101 : Understanding Ref Cursors
    Ref cursors are not supposed to be used within PL/SQL or SQL for that matter, though people keep on insisting on doing this for some reason.
    http://download.oracle.com/docs/cd/E11882_01/appdev.112/e10472/static.htm#CIHCJBJJ
    Purpose of Cursor Variables
    You use cursor variables to pass query result sets between PL/SQL stored subprograms and their clients. This is possible because PL/SQL and its clients share a pointer to the work area where the result set is stored.A ref cursor is supposed to be passed back to a procedural client language, such as Java or .Net.
    If you want to re-use a SQL statement in multiple other PL/SQL or SQL statements you would use a view.

  • Ho to make a variable mandatory or optional?

    Hi All,
        Please let me know where in the Query designer is the option to make a variable mandatory or optional?
    Thanks!

    Hi All,
         Thanks for the reply, that was very helpful. But now when i right click on the selected variable, the screen where i cud edit shows up and i see that variable entry is "Optional" & i need to change that to Mandatory but the problem is the screen is blanked out, that is i cannot make any changes, i can only see but not edit. But there are some other variables were i can change them from optional to mandatory but not this one...can you pls throw some light on this?
    Thanks a lot!

  • Cursor variable persistence (or lack of) - workarounds ?

    Using 11.1.0.7; want to be able to pass a query SQL statement out of a client to a database package and have the package execute the query and return N rows out of the query, and later serve requests from client for the next N records etc. Having opened the cursor I then want to be able to retain a reference to it for the secondary / subsequent look-ups. The restrictions on package cursor variable definition prevent the obvious solution(s). Wondering whether others had experience of delivering such a solution ?
    Have trialled use of DBMS_SQL, but under 11g run into restrictions relating to new 11g security features, which the docco suggests can be disabled, but reluctant to do so. Returning the cursor reference to client (Oracle Forms) could be the next option, but would prefer to not. Figured this might've already been solved ...?
    Thanks,

    robli wrote:
    I can pass the ref cursor back to the client but there's no way to otherwise persist the ref cursor in the database session - true ?Yes you can persist ref cursors in 11g:
    SQL> --// custom data type for storing DBMS_SQL cursor handles
    SQL> create or replace type TCursorList is table of number;
      2  /
    Type created.
    SQL> --// our interface for storing (persisting) ref cursor handles in PL/SQ:
    SQL> create or replace package CursorContainer as
      2          --// store a ref cursor (and get an index number in return to
      3          --// access that ref cursor again)
      4          procedure StoreRefCursor( c in out sys_refcursor, idx out number );
      5 
      6          --// retrieve a stored ref cursor handle
      7          function GetRefCursor( idx number ) return sys_refcursor;
      8 
      9          function CursorList return TCursorList;
    10  end;
    11  /
    Package created.
    SQL>
    SQL> create or replace package body CursorContainer as
      2          --// actual variable/collection that contains the handles
      3          cursors         TCursorList;
      4 
      5          procedure StoreRefCursor( c in out sys_refcursor, idx out number ) is
      6          begin
      7                  if cursors is null then
      8                          cursors := new TCursorList();
      9                  end if;
    10 
    11                  cursors.Extend(1);
    12                  cursors( cursors.Count ) := DBMS_SQL.To_Cursor_Number( c );
    13 
    14                  idx := cursors.Count;
    15          end;
    16 
    17          function GetRefCursor( idx number ) return sys_refcursor is
    18          begin
    19                  return(
    20                          DBMS_SQL.To_RefCursor(
    21                                  cursors( idx )
    22                          )
    23                  );
    24          end;
    25 
    26          function CursorList return TCursorList is
    27          begin
    28                  return( cursors );
    29          end;
    30 
    31  end;
    32  /
    Package body created.
    SQL>
    SQL> --// create and store 2 ref cursors
    SQL> declare
      2          c1      sys_refcursor;
      3          c2      sys_refcursor;
      4          n       number;
      5  begin
      6          open c1 for select sysdate from dual;
      7          open c2 for select rownum, d.dummy from dual d;
      8 
      9          CursorContainer.StoreRefCursor( c1, n );
    10          CursorContainer.StoreRefCursor( c2, n );
    11  end;
    12  /
    PL/SQL procedure successfully completed.
    SQL>
    SQL> --// what handles did we store?
    SQL> select column_value as CURSOR_HANDLE from TABLE(CursorContainer.CursorList);
    CURSOR_HANDLE
        388610362
         54290194
    SQL>
    SQL> --// we define a ref cursor pointer on the client side
    SQL> var c refcursor
    SQL> --// okay, we now consume these stored ref cursor handles
    SQL> --// grab cursor 1, consume and close it
    SQL> exec :c := CursorContainer.GetRefCursor(1);
    PL/SQL procedure successfully completed.
    SQL> print :c
    SYSDATE
    2011-03-02 13:56:22
    SQL>
    SQL> --// grab cursor 2, consume and close it
    SQL> exec :c := CursorContainer.GetRefCursor(2);
    PL/SQL procedure successfully completed.
    SQL> print :c
        ROWNUM DUM
             1 X
    SQL> I would however question such an interface for storing ref cursor handles... I have never in many years of Oracle client-server and PL/SQL development, ran into the requirement to persist ref cursor handles in PL/SQL(either for later consumption in PL/SQL, or consumption by an external client).
    The approach does not sound very robust to me.

  • Cursor Variable Arguments

    Migration Workbench Ver 1.2.2 has migrated an SQL Server 6.5
    strored procedure as a package containing only the Cursor
    variable and a procedure with INOUT parameter with packaged
    cusorvariable as one of the parameters to Oracle 8.0.5.
    How do you execute this procedure from SQL + and from another
    PL/SQL block where you have to retrive the data elements of the
    cursor.(ie.How do you input the cursor variable parameter in the
    EXECUTE stored procedure command.)An example of the type is
    appreciated.
    null

    Surendra,
    Using refcursors between procedures is covered in the 'Wrong
    number or types of argument in call to stored proc' 4 jun thread,
    with reference to the manuals.
    Using refcursor bind variables is covered in the sqlplus user
    guide and reference reproduced below (from the 8.1.5 version,
    also in 8.0.5) available on line on OTN.
    Hope that helps,
    Turloch
    Oracle Migration Workbench Team
    Using REFCURSOR Bind Variables
    SQL*Plus REFCURSOR bind variables allow SQL*Plus to fetch and
    format the results of a SELECT statement contained in a PL/SQL
    block.
    REFCURSOR bind variables can also be used to reference PL/SQL
    cursor variables in stored procedures. This allows you to store
    SELECT statements in the database and reference them from
    SQL*Plus.
    A REFCURSOR bind variable can also be returned from a stored
    function.
    Note:
    You must have Oracle7, Release 7.3 or above to assign
    the return value of a stored function to a
    REFCURSOR variable.
    Example 3-18 Creating, Referencing, and Displaying REFCURSOR Bind
    Variables
    To create, reference and display a REFCURSOR bind variable, first
    declare a local bind variable of the REFCURSOR datatype
    SQL> VARIABLE dept_sel REFCURSOR
    Next, enter a PL/SQL block that uses the bind variable in an OPEN
    ... FOR SELECT statement. This statement opens a cursor variable
    and executes a query. See the PL/SQL User's Guide and Reference
    for information on the OPEN command and cursor variables.
    In this example we are binding the SQL*Plus dept_sel bind
    variable to the cursor variable.
    SQL> BEGIN
    2 OPEN :dept_sel FOR SELECT * FROM DEPT;
    3 END;
    4 /
    PL/SQL procedure successfully completed.
    The results from the SELECT statement can now be displayed in
    SQL*Plus with the PRINT command.
    SQL> PRINT dept_sel
    DEPTNO DNAME LOC
    10 ACCOUNTING NEW YORK
    20 RESEARCH DALLAS
    30 SALES CHICAGO
    40 OPERATIONS BOSTON
    The PRINT statement also closes the cursor. To reprint the
    results, the PL/SQL block must be executed again before using
    PRINT.
    Example 3-19 Using REFCURSOR Variables in Stored Procedures
    A REFCURSOR bind variable is passed as a parameter to a
    procedure. The parameter has a REF CURSOR type. First, define the
    type.
    SQL> CREATE OR REPLACE PACKAGE cv_types AS
    2 TYPE DeptCurTyp is REF CURSOR RETURN dept%ROWTYPE;
    3 END cv_types;
    4 /
    Package created.
    Next, create the stored procedure containing an OPEN ... FOR
    SELECT statement.
    SQL> CREATE OR REPLACE PROCEDURE dept_rpt
    2 (dept_cv IN OUT cv_types.DeptCurTyp) AS
    3 BEGIN
    4 OPEN dept_cv FOR SELECT * FROM DEPT;
    5 END;
    6 /
    Procedure successfully completed.
    Execute the procedure with a SQL*Plus bind variable as the
    parameter.
    SQL> VARIABLE odcv REFCURSOR
    SQL> EXECUTE dept_rpt(:odcv)
    PL/SQL procedure successfully completed.
    Now print the bind variable.
    SQL> PRINT odcv
    DEPTNO DNAME LOC
    10 ACCOUNTING NEW YORK
    20 RESEARCH DALLAS
    30 SALES CHICAGO
    40 OPERATIONS BOSTON
    The procedure can be executed multiple times using the same or a
    different REFCURSOR bind variable.
    SQL> VARIABLE pcv REFCURSOR
    SQL> EXECUTE dept_rpt(:pcv)
    PL/SQL procedure successfully completed.
    SQL> PRINT pcv
    DEPTNO DNAME LOC
    10 ACCOUNTING NEW YORK
    20 RESEARCH DALLAS
    30 SALES CHICAGO
    40 OPERATIONS BOSTON
    Example 3-20 Using REFCURSOR Variables in Stored Functions
    Create a stored function containing an OPEN ... FOR SELECT
    statement:
    SQL> CREATE OR REPLACE FUNCTION dept_fn RETURN -
    cv_types.DeptCurTyp IS2 resultset cv_types.DeptCurTyp;
    3 BEGIN
    4 OPEN resultset FOR SELECT * FROM DEPT;
    5 RETURN(resultset);
    6 END;
    7 /
    Function created.
    Execute the function.
    SQL> VARIABLE rc REFCURSOR
    SQL> EXECUTE :rc := dept_fn
    PL/SQL procedure successfully completed.
    Now print the bind variable.
    SQL> PRINT rc
    DEPTNO DNAME LOC
    10 ACCOUNTING NEW YORK
    20 RESEARCH DALLAS
    30 SALES CHICAGO
    40 OPERATIONS BOSTON
    4 rows selected
    The function can be executed multiple times using the same or a
    different REFCURSOR bind variable.
    SQL> EXECUTE :rc := dept_fn
    PL/SQL procedure successfully completed.
    SQL> PRINT rc
    DEPTNO DNAME LOC
    10 ACCOUNTING NEW YORK
    20 RESEARCH DALLAS
    30 SALES CHICAGO
    40 OPERATIONS BOSTON
    Surendra Kumar (guest) wrote:
    : Migration Workbench Ver 1.2.2 has migrated an SQL Server 6.5
    : strored procedure as a package containing only the Cursor
    : variable and a procedure with INOUT parameter with packaged
    : cusorvariable as one of the parameters to Oracle 8.0.5.
    : How do you execute this procedure from SQL + and from
    another
    : PL/SQL block where you have to retrive the data elements of the
    : cursor.(ie.How do you input the cursor variable parameter in
    the
    : EXECUTE stored procedure command.)An example of the type is
    : appreciated.
    Oracle Technology Network
    http://technet.oracle.com
    null

  • Passing where cluase as parameter for cursor

    I want to pass where clause of cursor as parameter.... how can I do that?
    say I want cursor as,
    cursor c1 is select fname, mname from person where :param;
    where :param is a value I want to pass in declare section

    I want to pass where clause of cursor as parameter.... how can I do that?Yes.
    cursor c1 is select fname, mname from person where :param;
    where :param is a value I want to pass in declare sectionYou can also shoot yourself in the foot using a 357 Magnum.
    Neither is recommended - unless you are a professional idiot. Which I doubt as these are typically your Darwin Award Winners.
    Why is it bad to to have "+WHERE :param+"?
    Bind variables. If the WHERE clause is passed as a dynamic string. this will usually be implemented in the following fashion:
    SQL> create or replace procedure smellyFoo( filterClause varchar2, refCur in out sys_refcursor ) is
      2  begin
      3          open refCur for
      4          'select owner, object_id, object_name from all_objects where owner != ''SYS'' and '||filterClause||' order by 1,2';
      5  end;
      6  /
    Procedure created.
    SQL>
    SQL> var c refcursor
    SQL> exec smellyFoo( 'object_type=''TABLE'' and rownum <11', :c );
    PL/SQL procedure successfully completed.
    SQL>
    SQL> print c
    OWNER       OBJECT_ID OBJECT_NAME
    OUTLN             452 OL$
    OUTLN             453 OL$HINTS
    OUTLN             456 OL$NODES
    SYSTEM           3621 MVIEW$_ADV_WORKLOAD
    SYSTEM           3624 MVIEW$_ADV_BASETABLE
    SYSTEM           3626 MVIEW$_ADV_SQLDEPEND
    SYSTEM           3628 MVIEW$_ADV_PRETTY
    SYSTEM           3630 MVIEW$_ADV_TEMP
    SYSTEM           3632 MVIEW$_ADV_FILTER
    SYSTEM           3634 MVIEW$_ADV_LOG
    10 rows selected.
    SQL>What's wrong with this? The filter clause contains literals. Not bind variables. Which means that non-sharable SQL will be created. This means more cursors (for same SQLs with different literal values) in the shared pool. Different sizes SQLs that leads to fragmentation of the shared pool memory. More hard parsing. Bigger delay in parsing as there are more cursors to scan in the shared pool (useless exercise) as there are no existing cursors that are sharable and can be re-used.
    So what would the correct way be? The client passing a filter clause as a proper bind variable string, and also passing (separately) the values for those bind variables. But this is not easy to code, especially when dealing with filter clauses that may contain no bind variables. or a 100 bind variables.
    Also, the call interface the client needs to use will become a lot more complex as the client now not only needs to build a proper string containing bind variables, it also need to make sure it pass the values for those variables in the correct order.
    So why? Why do any of this? What is the requirement that lead you to this "solution" where the client can dynamically decide on what the filter criteria is?
    Surely, there must be a reason to this madness of the client wanting to throw any filter clause at a SQL cursor... and surely, that is what needs to be identified and analysed and resolved - instead of wanting to create hacks like the above. Causing performance issues. Not to mention opening a security hole that is ideal for SQL injection.

  • Help in FOr cursor -

    hi all,
    The follwoing is my req - Below the written proc - can anyone check it is correct .
    1.     Write a procedure to compute the following using FOR cursor. Procedure should take 3 parameters. Empno - IN parameter, Empno IN parameter and this can be a default parameter. The OUT parameter should return the total cost to the company.
    DA = 15% of sal
    HRA = 20% of sal
    TA = 8% of sal
    Special Allowance will be decided based on the service in the company
    < 1 year                Nil
    1 year and < 2 years      10% of salSrividhya Maha...     >2 years and < 4 years      15% of sal
    5 years           20% of salcreate or replace procedure testing(p_empno in number default 10,v_cost out number)
    as
    v_salary number;
    v_months number;
    cursor mycur is
      SELECT salary from emp where empno = p_empno;
    begin
    for emp_rec in mycur
    LOOP
    SELECT round(months_between(sysdate,hire_date))into v_months from emp
      WHERE empno= p_empno;
    IF v_months < 12 then
    v_salary := salary *12;
    elsif
    v_months >12 and v_months <24
    v_salary := salary *12;
    dbms_output.put_line('employee salary'||15/100*salary+20/100*salary+
                                       8/100*salary +v_salary);
    end if;
    end loop;
    end;
    [\pre]
    cheers                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    1) consider using FUNCTION to return the cost result, rather than an out parameter; that would allow you to call it in SQL (for example in an UPDATE)
    2) Your requirement says THREE parameters - but one of them is EMPNO (twice)
    3) Why allow default of EMPNO to 10?
    4) You have used ROUND - that means 11.6 months is treated as 1 year. You should use FLOOR instead (or jus compare real numbers)
    5) Your requriement leaves out 4-5 years service entirely - was that intentional?
    6) The whole section is incorrect:
    - refer to cursor variables using the record name, eg:
    v_salary := emp_rec.salary * 12;
    - You have assigned to local variable v_salary, but not to OUT variable v_cost.
    - your DBMS_OUTPUT.PUT_LINE gives you salary * (0.15+0.2+0.08) = 0.43*salary - why?
    7) You could put the whole thing into a single piece of SQL
    SELECT case
                  when months_between(sysdate,hire_date) < 12.0 then null
                  when months_between(sysdate,hire_date) < 24.0 then 0.10
                  when months_between(sysdate,hire_date) < 48.0 then 0.15
                  when months_between(sysdate,hire_date) >= 60.0 then 0.20
                 else null
                 end * salary  "Allowance"
    from   emp
    where {your where clause}
    /(multiply by 12 if salary is monthly and you need annual allowance).
    HTH
    Regards Nigel

Maybe you are looking for

  • Error in displaying date time value in Thai Windows OS browser.

    Hi, I have a problem displaying date time in the browser which is installed with Thai Windows OS. The time portion (the subset of datetime) does seemed to show correctly. Initially i am suspecting the virtual machine problem but i tried on bith java

  • TA23480 Publish podcast Network time out

    When I go to submit a new podcast in the iTunes store, it returns the error: We could not complete your iTunes Store request. The network connection was lost. Here's the feed: http://www.sharedoterra.com/wp-content/uploads/2012/05/Podcasts/podcast.xm

  • Migrating Smartform to Adobe form

    Hi All,   I have Standard SAP  Purchase order, i have cpoied into  Z-Smatform.   then i have to migrating the same smartform to Adobe form.   While migrating from smartform to Adobe i am getting dump like..   There is already a type called TY_TEXT ..

  • Find the Manager for Group

    If this isn't a good place to ask this question I applogize in adavance if you could provide a link to the correct area I should ask/post this I would appreciate it. Otherwise... The end goal is to fill in the Managedby atribute for a lot of secuirty

  • Send Data from BPEL to BAM

    Hello, I have problem right now. I tried to send data from bpel to BAM (without enterprise link) but It failed. Then I found error like this: java.io.IOException: URL is invalid /OracleBAMWS/inspection.wsil [407]      at com.collaxa.cube.engine.senso