Return cursor variable in function

I have three different sql queries already joined to diff tables, like query1 is made by joining 4 diff tables.
query1----select a,b,c,x from t1(set of 4 tables)
query2----select e,f from t2(set of 3 tables) where t1.x=t2.x
query3----select g,h from t3(set of 3 tables) where t1.x=t3.x
I need to return the resultset on a single row something like this_
a,b,c,x,e,f,g,h
I am using the above queries in a function and to return the result set using cursor variable as the return type for the function.
Please suggest a suitable solution design.
Thanks.

I have only single column in query1 which is referencing to query2 and query 3. So further joining them is not preferred. There is no escape from joining them. It will probably be the most effective solution.
That said you might consider to restructure/review your whole involved select(s).
Translating Laurents proposition to your nomenclature you could finally end up with something like
CREATE FUNCTION f (p_st your_data_type)
   RETURN sys_refcursor
AS
BEGIN
   OPEN cur FOR
      SELECT *
        FROM query1, query2, query3
       WHERE st = p_st AND query1.ID = query2.ID AND query1.ID = query3.ID;
   RETURN cur;
END;

Similar Messages

  • Return multiple variables from function via DBLINK

    hey,
    I've created a function for use by another database through a dblink.
    I created the function to return a ref cursor but
    have since found out that this is not allowed so i'm looking for
    alternatives?
    Assuming I want to keep the function on our database (for maintainability reasons) what other options do i have?
    Two suggestions i've got are 1) to return a ',' delimited string
    or to have a number of OUT parameters. Is there any reason
    why either of these would not work or would be preferable to the other?
    Thanks for reading, any help much appreciated.
    BTW i'm new to PL/SQL so feel free to dumb it down.
    cheers.
    function....
    CREATE OR REPLACE FUNCTION "GET_SCHEME_DETAILS"
    IN_BRANCH IN VARCHAR2,
    IN_AGENCY IN VARCHAR2,
    IN_PRODUCT_SUFFIX IN VARCHAR2,
    IN_TERM IN INTEGER,
    IN_LOAN_START_DATE IN DATE
    RETURN sys_refcursor AS TYPE RESULTSET IS REF CURSOR;
    and its being called like this....
    select GET_SCHEME_DETAILS@PPPRO ( '864' , '500086' , 'M7' , 10 , TO_DATE ( '01/02/2010' , 'DD/MM/YYYY' ) ) FROM DUAL ;

    I would be amazed if that even compiled.
    The function should look something like:
    CREATE FUNCTION GET_SCHEME_DETAILS (in_branch          IN VARCHAR2,
                                        in_agency          IN VARCHAR2,
                                        in_product_suffix  IN VARCHAR2,
                                        in_term            IN INTEGER,
                                        in_loan_start_date IN DATE) RETURN sys_refcursor AS
       l_ref_cur SYS_REFCURSOR;
       < any other variables that need declaring >
    BEGIN
       OPEN l_ref_cur FOR
          <your select tstatment here>
       RETURN l_ref_cur;
    END;and you would call it from the other database like:
    DECLARE
       l_other_ref_cur SYS_REFCURSOR;
       < any other variables that need declaring  like one for each column in the ref cursor>
    BEGIN
       l_other_ref_cur := get_scheme_details@PPPRO ('864', '500086', 'M7', 10,
                                                    TO_DATE ( '01/02/2010' , 'DD/MM/YYYY' ));
       LOOP
          FETCH l_other_ref_cursor INTO <variable list>
          EXIT WHEN l_other_ref_cursor%NOT_FOUND;
          <do something with the values>
       END LOOP;
       CLOSE l_other_ref_cur;
    END;Having said that, if you are only expecting to get one row back, then you could just as easily use a procedure with out parameters.
    If you expect multiple rows back, you could also just do a query on the other database drectly using the db link assuming that the user that the db link uses to connect has appropriate privileges.
    HTH
    John

  • Returning 3 variables from function

    I pass into a certain function 4 variables, 3 of them are worked on and changed, how could I pass back the 3 changed variables? I C i could do pointers, is there anything like that in java?

    The_One wrote:
    theres no way of changing the variables i passed in automatically from another function? like just reassign them?No there isn't and there can't be, because Java uses pass-by-value. If you reassign the parameters, you'll only change the local copies of those parameters.
    The real object-oriented solution to this would be to return an object that contains those three values.
    And if the four values put in and the three values that you want to return are somehow related, then you might want to use an object as the input as well.
    Could you tell us what specific method you're talking about? Then we could suggest a Java-like solution.

  • OCI8: returning cursors from stored procedures

    The short version of my question is:
    In OCI8, how do open a cursor from the database stored procedure, return it to my C++ program and fetch from it, given that in OCI8 cursors and cursor functions are becoming obsoleted?
    The long version of the same question is:
    I am converting my C++ code from the Oracle 7.3 OCI driver to the Oracle8 OCI driver. One thing I did very frequently in Oracle 7.3 OCI code is open a multi-row select cursor within a stored procedure and return that cursor to my program. In the program, I would then do the fetching with the returned cursor. This was very useful, as it allows me to change the queries in the stored procedure (for example, to append information to certain columns or make some data in all uppercase) without recompiling the application due to a changed SQL string.
    My 7.3 psuedocode is as follows:
    stored procedure def:
    TYPE refCurTyp IS REF CURSOR;
    FUNCTION LoadEmployeeData RETURN refCurTyp;
    stored procedure body:
    FUNCTION LoadEmployeeData RETURN refCurTyp IS
    aCur refCurTyp;
    BEGIN
    OPEN aCur FOR
    SELECT emp_id, emp_name
    FROM employee_table
    ORDER BY emp_name;
    return aCur;
    END;
    OCI code: // all functions are simplified, not actual parameter listing
    // declare main cursor variable #1 and return cursor variable #2
    Cda_Def m_CDAstmt, m_CDAfunction;
    // open both cursors
    oopen(m_CDAstmt, ...);
    oopen(m_CDAfunction, ...);
    // bind cursor variable to cursor #2
    oparse(&m_CDAstmt, "BEGIN :CUR := MYPACKAGE.LoadEmployeeData; END;");
    obindps(&m_CDAstmt, SQLT_CUR, ":CUR", &m_CDAfunction);
    // run cursor #1
    oexn(&m_CDAstmt);
    // bind variables from cursor #2, and fetch
    odefineps(&m_CDAfunction, 1, SQLT_INT, &m_iEmpId);
    odefineps(&m_CDAfunction, 2, SQLT_CHAR, &m_pEmpName);
    while (!ofen(&m_CDAfunction))
    // loop: do something with fetch
    // values placed in m_iEmpID and m_pEmpName
    This works perfectly, and has really helped to make my code more maintainable. Problem is, in Oracle 8 OCI both cursors and the cursor functions (such as oopen()) are becoming obsoleted. Now it uses statement and environment handles. I know I can still use Cda_Def and cursors--for a while--within OCI8, but I need to know the official up-to-date method of returning a cursor from the database and fetching within my C++ code. Any code fragment, or explanation of what I need to do in OCI8 would be appreciated (perhaps I need to bind to a statement handle instead? But the stored procedure still returns a cursor.)
    The Oracle8 OCI has a new SQLT_ type, SQLT_RSET, which the header file defines as "result set type". Unfortunately, it's almost completely undocumented in the official documentation. Am I supposed to use this instead of the obsolete SQLT_CUR?
    Thanks,
    Glen Mazza

    Email me diorectly and I will get you some code that might help. I fail to see the relevance of posting this type of information in the JDeveloper forum.

  • 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!!!

  • Question about cursors in a function and how to return the results

    Hi all,
    Some tech info:
    I'm using Oracle 11G database and APEX 4.0.2.00.06
    I use three cursors in a function. My function is called in an APEX standard report, like this by example:
    SELECT fnc_exp(tab.arg1, tab,arg2) FROM table_exp tab;
    My question is: how can I return the values calculated from my function to a standard APEX report? Before, this function was used like this by Oracle Forms to fetch the cursors in the right table columns:
    open c_a;
    fetch c_a into :loc.arg1;
    close c_a;
    open c_b;
    fetch c_b into :loc.arg2, :loc.arg3, :loc.arg4, :loc.arg5;
    close c_b;
    Thanks for your advices!
    Maybe my solution is not right, if you have better ideas, please suggest :)
    PS: If you need more details, please ask which you need.

    Hi,
    I don't think you can do exactly like that in APEX.
    Go for a pipelined function if you want the value be returned from the function.

  • Executing a Function in a Stored Procedure to Return Cursor

    I have a function named f_CPCRBPBR who base on the following types
    CREATE Or Replace TYPE RecType_fAC
    AS OBJECT ( << Structure >>);
    CREATE Or Replace TYPE Tbl_fAC
    AS TABLE OF RecType_fAC;
    Create Or Replace
    Function f_CPCRBPBR (
    i_Vtp Varchar2,
    i_Mnth Varchar2,
    i_Location Varchar2,
    i_vno integer,
    i_vnoTo integer,
    St_Date Varchar2,
    En_Date Varchar2
    Return TBL_fAC
    Pipelined
    Is
    RetVal RecType_fAC;
    Begin
    Now the problem is that I want to Call this Function from Within a Procedure who would return the Recordset..
    can any body suggest..
    I want to use the Record Type used for the Said Function..
    Please Help..

    This is Excellent .. This is great.. actually this is marvellous.. can u please defined a bit about Sys_RefCursor...
    this is an excellent thing..
    I finally Concluded the procedure as follows who not only called but also returned the cursor..
    Create Or Replace Procedure p_CPCRBPBR (TstCrsr In Out Sys_RefCursor,
    i_Vtp Varchar2,
    i_Mnth Varchar2,
    i_Location Varchar2,
    i_vno integer,
    i_vnoTo integer,
    St_Date Varchar2,
    En_Date Varchar2
    as
    Begin
    Open TstCrsr FOr
    Select * from Table(f_CPCRBPBR (i_VTP, i_Mnth, i_Location, i_VNo, i_VNoTo, '', ''));
    End;
    Can u please help me what will be the exact syntax to call / test this procedure in SQL Developer..
    as if i try this procedure as
    Execute p_CPCRBPBR null, 'CP', '01', 'L', 1, 1, null, null
    it give error Invalid SQL Statement ..
    2. Can u please check this code and refer me a solution for Calling this function
    create or replace function NewTest (iEN Integer)
    return sys_refcursor
    as
    rc sys_refcursor;
    begin
    open rc for select * from Scott.Emp Where EmpNo=iEN;
    return rc;
    end;
    This function easily created but when i tried to execute this with the following statement
    Select * from Table(NewTest (7369))
    It gives error
    Cannot Access Rows From a Non-Nested Table Item..
    .. Thanx for ur patience...

  • How to execute function having return cursor

    hi all
    Please tell me
    How to execute function having return cursor
    regards

    CREATE OR REPLACE FUNCTION sp_get_stocks(v_price IN NUMBER)
    RETURN types.ref_cursor
    AS
    stock_cursor types.ref_cursor;
    BEGIN
    OPEN stock_cursor FOR
    SELECT ric,price,updated FROM stock_prices
    WHERE price < v_price;
    RETURN stock_cursor;
    END;
    SQL> exec :results := sp_get_stocks(20.0)
    PL/SQL procedure successfully completed.
    Message was edited by:
    chenks

  • Pl/sql function body returning SQL query - Print function

    Hello all,
    I have pl/sql function body returning SQL query for my reports for my new project that I am developing. We dont have any BI tool or anything for APEX so we use Oracle reports to get the same reports to be printed in PDF format. I had been using SQL function for Reports all these days and grabbing the data using SQL query was easy in Oracle reports. But this time we had atleast 8 fields in search criteria and hence I thouhgt PL/sql function body returning SQL query could be something easy to handle that scenario. We have 11 such reports in our project. Now when we tried to use the same PL/sql function to oracle reports , I was told by one of our Oracle reports expert, that we have to write it into functions and use it in SQL query to get the Reports in Oracle reports. Is there any Easy way to convert the same Pl/SQL function or get a PDF format of the same report in APEX without going thru the much pains of rewriting the whole SQL Query.
    thank you
    Devisri

    Hi,
    give this a go.
    I can't test it as I don't have the tables in my schema.
    create or replace package MK_TEST_PF is
    -- Author  : MK
    -- Created : 21/06/2010 16:30:19
    -- Purpose : FOR LUCY_DISCOVER
    -- Public type declarations
    /*     -- just guess the table row types.....
         -- otherwise it won't compile
         type test_rec is record
              (INV REP.inv%type
              ,cNUMBER REP.cNUMBER%type
              ,OPENDATE REP.OPENDATE%type
              ,TARGETDATE REP.ESTCOMPLETE%type
              ,DATECLOSED REP.COMPLETED%type
              ,STATUS REP.STATUS%type
              ,cCODE REP.cCODE%type
              ,line varchar2(4000)
              ,SIGc varchar2(4000)
              ,CLASS REP.CLASS%type
              ,SUMM REP.SUMM%type
              ,AREA REP.AREA%type
         type test_rec is record
              (INV varchar2(4000)
              ,cNUMBER varchar2(4000)
              ,OPENDATE varchar2(4000)
              ,TARGETDATE varchar2(4000)
              ,DATECLOSED varchar2(4000)
              ,STATUS varchar2(4000)
              ,cCODE varchar2(4000)
              ,line varchar2(4000)
              ,SIGc varchar2(4000)
              ,CLASS varchar2(4000)
              ,SUMM varchar2(4000)
              ,AREA varchar2(4000)
         type test_tab is table of test_rec;
    -- Public constant declarations
    -- Public variable declarations
    -- Public function and procedure declarations
    end MK_TEST_PF;
    create or replace package body MK_TEST_PF is
    -- Private type declarations
    -- Private constant declarations
    -- Private variable declarations
    -- Function and procedure implementations
         function get_query_f
              (p_inv VARCHAR2 := UPPER(v('P44_INV'))
              ,p_reg VARCHAR2 := UPPER(v('P44_CLASS'))
              ,p_proarea VARCHAR2 := UPPER(v('P44_PROGRAM_AREA'))
              ,p_disp VARCHAR2 := UPPER(v('P44_DISPOSITION'))
              ,p_coding VARCHAR2 := UPPER(v('P44_CODING'))
              ,p_status VARCHAR2 := UPPER(v('P44_STATUS'))
              ,p_SIG VARCHAR2 := UPPER(v('P44_SIG_c'))
              ,p_inc_sum VARCHAR2 := UPPER(v('P44_INCLUDE_SUMM_FIELD'))
              ,p_word VARCHAR2 := UPPER(v('P44_WORD_IN_SUMM'))
              ,p_timeframe VARCHAR2 := UPPER(v('P44_TIME_FRAME'))
              ,p_rec VARCHAR2 := UPPER(v('P44_RECORD_KEEPING'))
              ,p_WORD_IN_SUMM VARCHAR2 := UPPER(v('P44_WORD_IN_SUMM'))
              ,p_ON_AFTER VARCHAR2 := UPPER(v('P44_ON_AFTER'))
              ,p_ON_BEFORE VARCHAR2 := UPPER(v('P44_ON_BEFORE'))
              return varchar2
         is
              v_sql VARCHAR2(5000);
         --     v_inv VARCHAR2(100);
         --     v_reg VARCHAR2(100);
         --     v_proarea VARCHAR2(100);
         --     v_status VARCHAR2(100);
         --     v_SIG VARCHAR2(100);
         --     v_disp VARCHAR2(100);
         --     v_coding VARCHAR2(100);
         --     v_inc_sum VARCHAR2(4);
         --     v_word VARCHAR2(4000);
              v_wildcard VARCHAR2(2000);
         --     v_timeframe VARCHAR2(100);
         --     v_rec VARCHAR2(5);
              v_record VARCHAR2(5);
              v_open VARCHAR2(100);
              v_closed VARCHAR2(100);
              v_PEND VARCHAR2(100);
              v_refSIG VARCHAR2(100);
              v_refreg VARCHAR2(100);
              v_refother VARCHAR2(100);
              v_y varchar2(100);
         BEGIN
              --v_inv := UPPER(v('P44_INV')) ;
              v_record := 'R%';
              v_wildcard := '%';
              v_open := 'OPEN';
              v_closed := 'CLOSED';
              v_PEND := 'PEND';
              v_refSIG := 'REF - SIG';
              v_refreg := 'REF - CLASS';
              v_refother := 'REF - OTHER';
              v_y := 'Y';
              v_sql := 'SELECT REP.INV as INV, REP.cNUMBER as cNUMBER, REP.OPENDATE as OPENDATE,
              REP.ESTCOMPLETE as TARGETDATE, REP.COMPLETED as DATECLOSED, REP.STATUS as STATUS,
              REP.cCODE as cCODE, apex_item.checkbox(1,REP.line,null,'''||v_y||''') line , apex_item.checkbox(1,REP.SIG,null,'''||v_y||''') SIGc ,
              REP.CLASS as CLASS, REP.SUMM as SUMM, REP.AREA as AREA from REP where 1=1';
              IF p_rec is not null then
                   IF p_rec = 'E' then
                        v_sql := v_sql|| ' and upper(REP.cnumber) not like '''||v_record||'''';
                   ELSIF p_rec = 'D' then
                        v_sql := v_sql|| ' and upper(REP.cnumber) like '''||v_record||'''';
                   ELSIF p_rec = 'I' then
                        v_sql := v_sql|| ' and REP.cnumber = REP.cnumber ';
                   end if ;
              end if ;
              IF upper(p_status) not like '%NULL%' then
                   IF upper(p_status) like '%OPEN%' then
                   v_sql := v_sql||' AND upper(REP.status) like '''||v_open||'''';
                   ELSIF upper(p_status) like '%CLOSED%' then
                   v_sql := v_sql||' AND upper(REP.status) like '''||v_closed||'''';
                   ELSIF upper(v_PEND) like '%PEND%' then
                   v_sql := v_sql||' AND upper(REP.status) like '''||v_PEND||'''';
                   ELSIF upper(v_refSIG) like '%REF - SIG%' then
                   v_sql := v_sql||' AND upper(REP.status) like '''||v_refSIG||'''';
                   ELSIF upper(v_refreg) like '%REF - CLASS%' then
                   v_sql := v_sql||' AND upper(REP.status) like '''||v_refreg||'''';
                   ELSIF upper(v_refother) like '%REF - OTHER%' then
                   v_sql := v_sql||' AND upper(REP.status) like '''||v_refother||'''';
                   END IF ;
              END IF ;
              IF p_inv = 'NULL' THEN
                   v_sql := v_sql||' AND instr(upper(REP.INV),'''||p_inv||''') > 0';
              END IF ;
              IF p_reg = 'NULL' THEN
                   v_sql := v_sql||' AND instr(upper(REP.CLASS),'''||p_reg||''') > 0';
              END IF ;
              IF p_proarea = 'NULL' THEN
                   v_sql := v_sql||' AND instr(upper(REP.AREA),'''||p_proarea||''') > 0';
              END IF ;
              IF p_disp = 'NULL' THEN
                   v_sql := v_sql||' AND instr(upper(REP.disposition),'''||p_disp||''') > 0';
              END IF ;
              IF p_coding = 'NULL' THEN
                   v_sql := v_sql||' AND instr(upper(REP.ccode),'''||p_coding||''') > 0';
              END IF ;
              IF p_SIG = ' ' THEN
                   v_sql := v_sql||' AND instr(upper(REP.SIG),'''||p_SIG||''') > 0';
              END IF ;
              IF p_word is not null then
                   v_sql := v_sql|| ' and
                   instr(upper(REP.SUMM),
                   upper(nvl('''||p_WORD_IN_SUMM||''',REP.SUMM))) > 0';
              end if ;
              If p_timeframe is not null then
                   if upper(p_timeframe) = 'OPEN' then
                   v_sql := v_sql|| ' and to_date(REP.opendate) between to_date ('''||p_ON_AFTER||''') and to_date('''||p_ON_BEFORE||''')';
                   elsif upper(p_timeframe) = 'CLOSED' then
                   v_sql := v_sql|| ' and to_date(REP.completed) between to_date ('''||p_ON_AFTER||''') and to_date('''||p_ON_BEFORE||''')';
                   elsif upper(p_timeframe) = 'EST' then
                   v_sql := v_sql|| ' and to_date(REP.estcomplete) between to_date ('''||p_ON_AFTER||''') and to_date('''||p_ON_BEFORE||''')';
                   end if;
              end if;
              v_sql := v_sql ||' order by REP.INV ';
              return v_sql;
         end get_query_f;
         function test_pf
              (p_inv VARCHAR2 := UPPER(v('P44_INV'))
              ,p_reg VARCHAR2 := UPPER(v('P44_CLASS'))
              ,p_proarea VARCHAR2 := UPPER(v('P44_PROGRAM_AREA'))
              ,p_disp VARCHAR2 := UPPER(v('P44_DISPOSITION'))
              ,p_coding VARCHAR2 := UPPER(v('P44_CODING'))
              ,p_status VARCHAR2 := UPPER(v('P44_STATUS'))
              ,p_SIG VARCHAR2 := UPPER(v('P44_SIG_c'))
              ,p_inc_sum VARCHAR2 := UPPER(v('P44_INCLUDE_SUMM_FIELD'))
              ,p_word VARCHAR2 := UPPER(v('P44_WORD_IN_SUMM'))
              ,p_timeframe VARCHAR2 := UPPER(v('P44_TIME_FRAME'))
              ,p_rec VARCHAR2 := UPPER(v('P44_RECORD_KEEPING'))
              ,p_WORD_IN_SUMM VARCHAR2 := UPPER(v('P44_WORD_IN_SUMM'))
              ,p_ON_AFTER VARCHAR2 := UPPER(v('P44_ON_AFTER'))
              ,p_ON_BEFORE VARCHAR2 := UPPER(v('P44_ON_BEFORE'))
              RETURN test_tab PIPELINED
         is
              type test_c is ref cursor;
              v_row test_tab;
              v_sql varchar2(4000);
              v_cursor test_c;
         begin
              v_sql := get_query_f
                   (p_inv
                   ,p_reg
                   ,p_proarea
                   ,p_disp
                   ,p_coding
                   ,p_status
                   ,p_SIG
                   ,p_inc_sum
                   ,p_word
                   ,p_timeframe
                   ,p_rec
                   ,p_WORD_IN_SUMM
                   ,p_ON_AFTER
                   ,p_ON_BEFORE
              open v_cursor for v_sql;
              fetch v_cursor bulk collect into v_row;
              close v_cursor;
              for i in 1 .. v_row.count loop
                   pipe row (v_row(i));
              end loop;
              return;
         end test_pf;
    end MK_TEST_PF;
    /Regards
    Michael

  • REF CURSOR problem .. function call from select

    Hello,
    I am still on the search for a way to call a function from with in a select statement.
    I've done it in SQL*Plus like this and it works.
    SELECT name, f_format(name) FROM user WHERE id = 12;
    This returns first the unformatted (raw) version of the stored value for name and then the formmtted version of the stored value of name.
    Since multiple names will be returned I need to user a REF CURSOR (cursor variable). The above select statement does not work from within the OPEN . .FOR clause necessary for a REF CURSOR.
    What can I do instead? My goal is to return multiple records of formatted names.
    null

    I have declared the reference cursor as a weak one. Thank you for clarifying that though. I was wondering if it made a difference. Here is a simple package that shows you what I am trying to do. I will include the errors at the bottom. Please have a look and let me know what you think is wrong.
    /*--------- PL/SQL ------------*/
    CREATE OR REPLACE PACKAGE test_refcur AS
    PROCEDURE decrypt (
    i_string IN VARCHAR2
    ,o_string OUT VARCHAR2
    TYPE PwdCurTyp IS REF CURSOR;
    PROCEDURE get_pwd_info (
    i_user_id IN NUMBER
    ,io_pwd_cv IN OUT PwdCurTyp
    END test_refcur;
    CREATE OR REPLACE PACKAGE BODY test_refcur AS
    FUNCTION f_decrypt (
    i_string IN VARCHAR2
    ) RETURN VARCHAR2 IS
    l_string VARCHAR2(64);
    l_string_dec VARCHAR2(32);
    BEGIN
    l_string := i_string;
    dbms_obfuscation_toolkit.DESDecrypt(
    input_string => l_string
    ,key_string =>'12345678'
    ,decrypted_string=> l_string_dec );
    RETURN l_string_dec;
    END f_decrypt;
    PROCEDURE decrypt (
    i_string IN VARCHAR2
    ,o_string OUT VARCHAR2
    ) IS
    BEGIN
    o_string := f_decrypt(i_string);
    END decrypt;
    PROCEDURE get_pwd_info (
    i_user_id IN NUMBER
    ,io_pwd_cv IN OUT PwdCurTyp
    ) IS
    BEGIN
    OPEN io_pwd_cv FOR
    SELECT
    label
    ,f_decrypt(user_name_text) AS dec_user_name
    ,f_decrypt(text) AS dec_pwd
    FROM
    code_pwd
    WHERE
    id = i_user_id;
    END get_pwd_info;
    END test_refcur;
    /*--------- SQL*Plus -----------*/
    Warning: Package Body created with compilation errors.
    SHOW ERRORSErrors for PACKAGE BODY TEST_REFCUR:
    LINE/COL ERROR
    28/13 PL/SQL: SQL Statement ignored
    30/18 PLS-00231: function 'F_DECRYPT' may not be used in SQL
    Then I made the SELECT statement dynamic.
    OPEN io_pwd_cv FOR
    'SELECT label, f_decrypt(user_name_text) AS dec_user_name, f_decrypt(text) AS dec_pwd FROM code_pwd WHERE id = i_user_id';
    It compiled fine.
    Package body created.
    So then I tried to do the following. .
    SET AUTOPRINT ON
    SET SERVEROUTPUT ON
    VARIABLE cv REFCURSOR
    EXECUTE test_refcur.get_pwd_info(18, :cv)begin test_refcur.get_pwd_info(18, :cv); end;
    ERROR at line 1:
    ORA-00904: invalid column name
    ORA-06512: at "K.TEST_REFCUR", line 27
    ORA-06512: at line 1
    If I change the SELECT statement to the following, this is what I get. .
    OPEN io_pwd_cv FOR
    SELECT label
    -- ,f_decrypt(user_name_text) AS dec_user_name
    -- ,f_decrypt(text) AS dec_pwd
    FROM code_pwd
    WHERE id = i_user_id;
    SET AUTOPRINT ON
    SET SERVEROUTPUT ON
    VARIABLE cv REFCURSOR
    EXECUTE test_refcur.get_pwd_info(18, :cv)PL/SQL procedure successfully completed.
    LABEL
    Development Server
    That tells me that at least something is working. How can I get everything else to work?

  • Open Cursor using other function/procedure

    Hi
    I have a procedure that return a cursor to Java, but if it send a parameter or other I wanted to call a procedure or function and return cursor to java , Is possible it ?
    Example
    PROCEDURE  XYZ ( P_ORD    IN  NUMBER,
                     p_CURSOR OUT SYS_REFCURSOR)
    IS
    BEGIN
       IF P_ORD  =1 THEN
          -- here I want to open cursor from other procedure/function
          OPEN P_CURSOR 
       ELSIF P_ORD  = 2 THEN
       END IF;
    END XYZ;Message was edited by:
    muttleychess

    Looking at your example code, you say you want to open a cursor from another procedure.
    I would suggest taking a step back and looking into the basics of procedural programming, especially in the area of variable scopes.
    The scope of the cursor declared in another procedure will be that it exists within that procedure only.
    In order to use another procedure's cursor you would have to call that procedure and have it return a SYS_REFCURSOR to your first procedure in the same manner you are trying to return a sys_refcursor to your Java code.

  • 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

  • How to return 4 variables by one return statement

    Hello Experts
    I’m trying to develop & run a function which will collect data from 2 difference tables. I accomplished it and stores all the information which I need in 4 variables. Now as we all know that function must has to return but I don’t know how to return all these 4 variable using 1 return. Can please somebody show me how I can return 4 variables.
    For reference here is my code
    create or replace function TOT_PURCH_SF (id_shopper in bb_basket.idshopper%type)
    return VARCHAR2
    as
    cursor cur_bb_basket is
    select idshopper, total
    from bb_basket;
    cursor cur_bb_shopper is
    select firstname, lastname
    from bb_shopper
    where idshopper = id_shopper;
    v_idshopper VARCHAR2(4);
    v_total bb_basket.total%type;
    v_gtotal bb_basket.total%type := 0;
    v_fname bb_shopper.firstname%type;
    v_lname bb_shopper.lastname%type;
    v_result VARCHAR2(200);
    begin
    if not (cur_bb_basket%isopen) then
    open cur_bb_basket;
    end if;
    loop
    fetch cur_bb_basket into v_idshopper, v_total;
    if (v_idshopper = id_shopper) then
    v_gtotal := v_gtotal + v_total;
    dbms_output.put_line('Shopper Info: '|| v_idshopper ||', '|| v_total);
    --exit;   
    end if;
    exit when cur_bb_basket%NOTFOUND;
    end loop;
    -- dbms_output.put_line('Shopper ID:'|| v_idshopper || ', TOTAL:' || v_gtotal);
    close cur_bb_basket;
    open cur_bb_shopper;
    fetch cur_bb_shopper into v_fname, v_lname;
    close cur_bb_shopper;
    dbms_output.put_line('Shopper ID:'|| v_idshopper || ', TOTAL:' || v_gtotal);
    dbms_output.put_line('FIRST NAME: '|| v_fname ||' LAST NAME: '|| v_lname);
    -- return (dbms_output.put_line('Shopper ID:'|| v_idshopper || ', TOTAL:' || v_gtotal));
    return 'test';
    end;
    Thanks a lot in advance

    Hi,
    If you want more than one variable returned by something, used a procedure with this variables declared as output variables. You only need to declare the procedure and keep the internal logic (with minimal changes).
    Your code modified (please remove dead code):
    CREATE OR REPLACE PROCEDURE TOT_PURCH_SF(id_shopper  IN bb_basket.idshopper%TYPE,
                                             p_idshopper OUT VARCHAR2,
                                             p_gtotal    OUT bb_basket.total%TYPE,
                                             p_fname     OUT bb_shopper.firstname%TYPE,
                                             p_lname     OUT bb_shopper.lastname%TYPE) AS
       CURSOR cur_bb_basket IS
          SELECT idshopper,
                 total
            FROM bb_basket;
       CURSOR cur_bb_shopper IS
          SELECT firstname,
                 lastname
            FROM bb_shopper
           WHERE idshopper = id_shopper;
       v_idshopper VARCHAR2(4);
       v_total     bb_basket.total%TYPE;
       v_gtotal    bb_basket.total%TYPE := 0;
       v_fname     bb_shopper.firstname%TYPE;
       v_lname     bb_shopper.lastname%TYPE;
       v_result    VARCHAR2(200);
    BEGIN
       IF NOT (cur_bb_basket%ISOPEN) THEN
          OPEN cur_bb_basket;
       END IF;
       LOOP
          FETCH cur_bb_basket
             INTO v_idshopper, v_total;
          IF (v_idshopper = id_shopper) THEN
             v_gtotal := v_gtotal + v_total;
             dbms_output.put_line('Shopper Info: ' || v_idshopper || ', ' || v_total);
             --exit;
          END IF;
          EXIT WHEN cur_bb_basket%NOTFOUND;
       END LOOP;
       -- dbms_output.put_line('Shopper ID:'|| v_idshopper || ', TOTAL:' || v_gtotal);
       CLOSE cur_bb_basket;
       OPEN cur_bb_shopper;
       FETCH cur_bb_shopper
          INTO v_fname, v_lname;
       CLOSE cur_bb_shopper;
       --dbms_output.put_line('Shopper ID:' || v_idshopper || ', TOTAL:' || v_gtotal);
       --dbms_output.put_line('FIRST NAME: ' || v_fname || ' LAST NAME: ' || v_lname);
       -- return (dbms_output.put_line('Shopper ID:'|| v_idshopper || ', TOTAL:' || v_gtotal));
       --RETURN 'test';
       p_idshopper := v_idshopper;
       p_gtotal    := v_gtotal;
       p_fname     := v_fname;
       p_lname     := v_lname;
    END;Regards,
    Tip: to post formatted code, please enclose it between {noformat}{noformat} tags (start and end tags are the same) :)
    Edited by: Walter Fernández on Mar 3, 2009 8:19 PM - Adding procedure (not tested)...
    Edited by: Walter Fernández on Mar 3, 2009 8:20 PM - Adding useful tip...                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Returning both raise_application_error and return value from db function...

    Hi ,
    I use Oracle 10g and forms10g.
    I have written a db packaged function such as:
    function fnc_ipologismos_xiliometron(code_poleis_apo_var in varchar2,code_poleis_pros_var in varchar2)
       return number
       is
        apostasi_var ref_apostaseis_poleon.apostasi%type;
        onomasia_pol_apo_var ref_poleis.onomasia%type;
        onomasia_pol_pros_var ref_poleis.onomasia%type;
        begin
         begin
            select onomasia into onomasia_pol_apo_var
              from ref_poleis
              where code_poleis=code_poleis_apo_var;
         end;
         begin
            select onomasia into onomasia_pol_pros_var
              from ref_poleis
              where code_poleis=code_poleis_pros_var;
         end;
         begin
          select apostasi into apostasi_var
           from ref_apostaseis_poleon
           where code_poleis_apo=code_poleis_apo_var and code_poleis_pros=code_poleis_pros_var;
          exception
           when no_data_found
    then
    apostasi_var:=0;
    return apostasi_var;
    raise_application_error(-20015,'a message');
    --return apostasi_var;
    end;      return apostasi_var;
        end;The problem is that when the exception written above (in bold) returns 0 and exits the function.... whereas i want this value to be returned as well as the message in the raise_application_error....
    I call this function in WHEN-VALIDATE-ITEM of a block item... such as:
    if pkg_mod3_general.fnc_ipologismos_xiliometron
    (:mod3_entoli_metakinisis.code_poleis_apo_type_id,:mod3_entoli_metakinisis.code_poleis_type_id)=0
                  and :mod3_entoli_metakinisis.seq_code_meso_metakin_type_id=2
                  then
                    raise form_trigger_failure;
      end if;     When the above condition is true then no message is displayed and the cursor sticks to the item(as the raise_application_error in the db packaged function is after the exit of the function) and when the condition is false then no message is displayed again ... as expected.....
    How is it get the desired result.....- get the message from the raise_application_error and the function returns 0.....?????
    Many thanks,
    Simon

    you cannot RETURN and RAISE a function.
    RETURN ends the function immediately
    RAISE ends the program unit and jumps in the EXCEPTION-Handler, if it exists. Else the function ends

Maybe you are looking for

  • How do i save files in icloud

    how do i save XL files in icloud?

  • Mapping runtime

    Can any one explain mapping runtime with documents pls

  • Help making a 3D cut sphere in Illustrator?

    Hello! So I'm a novice at making 3D objects in Illustrator. I'm attempting to make a cut sphere in Illustrator. I'm not sure if what I want to achieve is best done through pen tool and gradients or 3D revolve. Here are some screenshots of my attemps

  • Which user and which procedure takes snapshots for AWR in 10g??

    Hi, all. Which user and which procedure takes snapshots for AWR in 10g?? The snapshot interval is 1 hour. I checked dba_scheduler_job, and dba_job. However, I was not able to find a job which takes a snapshot. On EM, I can see snapshots are being tak

  • GR - refering to scheduling agreement(LPA)

    Hi All At the time of GR - refering to scheduling agreement(LPA) its showing the open order qty zero - if i changed maually(qty is the same as the todays GR qty) and i did check -error msg telling that qty exceeded the order qty. Plz help me to proce