Cursor in a procedure - Important pls...

All,

I have a package that has a procedure and has a parameter of type cursor. I want the output should return the value of collection

Scenario: in the emp table I have 3 files like this

ENO ename deptid
1 abc 100
XYZ 2 100
mno 3 300

Dept table

deptID dname
100 mkg
end 200

I invoked the package like that

declare
p_emp_type test_temp.emp_cursor%rowtype;

Start

test_temp.temp_proc (p_emp_type);
dbms_output.put_line ('inside the code');
dbms_output.put_line (p_emp_type.ename);
end;

But the anonymous block above returns the last the mno i.e emptable ename is not all return values! I want all enames output. Where I ve that went wrong?

Spec.SQL

create or replace
package test_temp authid current_user is

cursor emp_cursor is select ename, dname from EMP, dept
where emp.deptid = dept.deptid;

PROCEDURE temp_proc (p_emp_type OUT NOCOPY emp_cursor % rowtype);

end;

Body.SQL

create or replace
test_temp package body is


PROCEDURE temp_proc (p_emp_type OUT NOCOPY emp_cursor % rowtype) is

Start


for p_emp_typ emp_cursor loop
p_emp_type. Ename: = p_emp_typ.ename;

end loop;

end temp_proc;

end;

I showed you two how to do. One with Refcursor and the other with the function in pipeline.

create table emp
as
select 1 eno, 'abc' ename, 100 deptid from dual union all
select 2, 'xyz', 100 from dual union all
select 3, 'mno', 300 from dual;

create table dept
as
select 100 deptid, 'mkg' dname from dual union all
select 200, 'fin' from dual;

create or replace package emp_detail
as
  type rec is record (ename emp.ename%type, dname dept.dname%type);
  type tbl is table of rec;

  procedure print_emp_detail (pResult out sys_refcursor);
  function print_emp_detail return tbl pipelined;
end;
/
show err
create or replace package body emp_detail
as
  procedure print_emp_detail (pResult out sys_refcursor)
  is
  begin
    open pResult for
    select ename, dname
      from emp e
      join dept d
        on e.deptid = d.deptid;
  end;

  function print_emp_detail return tbl pipelined
  is
    lRec rec;
  begin
    for i in (
              select ename, dname
                from emp e
                join dept d
                  on e.deptid = d.deptid
             )
    loop
      lRec.ename := i.ename;
      lRec.dname := i.dname;
      pipe row (lRec);
    end loop;
    return;
  end;
end;
/
show err

select * from table(emp_detail.print_emp_detail)
/
var rc refcursor
exec emp_detail.print_emp_detail(:rc)
print rc

Tags: Database

Similar Questions

  • How to pass the value of the cursor in the procedure to use as dblink

    Hello

    I have a cursor in the procedure. I am inserting some values into the destination table by querying the source table using dblink. And I'm collecting this db link in the cursor. So, my question is how I will pass on the value of dblink values read from the cursor in each iteration? This is my procedure.

    CREATE OR REPLACE
        PROCEDURE desktop_proc
        AS
          v_name VARCHAR2(10);
          v_dblink  VARCHAR2(10);
          CURSOR db_cur
          IS
            SELECT PNAME,OLTP_DBLINK
            FROM PDATA
            WHERE pname in ('RMA','RNA')
            ORDER BY PNAME;
        BEGIN
          OPEN db_cur;
          LOOP
            FETCH db_cur INTO v_name,v_dblink;
            EXIT WHEN db_cur%NOTFOUND;
            INSERT INTO desktop_lite
              (
                Datestamp,
                pname,
                Db_name,
                Company_name
              )
            SELECT Date_Range,
              v_name,   -- local variable
              dbname,
              Company_name
              FROM
              (SELECT bu.datestamp Date_Range,
                      (SELECT name FROM v$database@v_dblink) dbname,
                      bu.name Company_name
               FROM dboltp.s_org_ext@v_dblink bu
               INNER JOIN com_unique uusers ON (uusers.bu_id = bu.row_id)
              );
          END LOOP;
          CLOSE db_cur;
        END desktop_proc;
    

    Thank you

    Maybe this can work for you:

    CREATE OR REPLACE
        PROCEDURE desktop_proc
        AS
          v_name    VARCHAR2(10);
          v_dblink  VARCHAR2(10);
          v_statement varchar2(2000);
          CURSOR db_cur
          IS
            SELECT 'test_name' dual_name, 'test_dbl' dual_link
            FROM dual;
        BEGIN
          OPEN db_cur;
          LOOP
            FETCH db_cur INTO v_name,v_dblink;
            EXIT WHEN db_cur%NOTFOUND;
            v_statement := '
            INSERT INTO desktop_lite
              (
                Datestamp,
                pname,
                Db_name,
                Company_name
              )
            SELECT Date_Range,
              '''|| v_name || ''',
              dbname,
              Company_name
              FROM
              (SELECT bu.datestamp Date_Range,
                      (SELECT name FROM v$database@' || v_dblink || ') dbname,
                      bu.name Company_name
               FROM dboltp.s_org_ext@' || v_dblink || ' bu
               INNER JOIN com_unique uusers ON (uusers.bu_id = bu.row_id)
              )';
            dbms_output.put_line (v_statement);
    --            execute immediate v_statement;    -- first look at the statments you produce, then uncomment and test it
           END LOOP;
           CLOSE db_cur;
    END desktop_proc;
    /
    show err
    
    exec desktop_proc
    

    This is my result, it seems that this can work:

    INSERT INTO desktop_lite

    (

    Timestamp,

    PName,

    Db_name,

    Company_name

    )

    SELECT Date_Range,

    "test_name."

    dbname,

    Company_name

    Of

    (SELECT bu.datestamp Date_Range,

    Dbname (SELECT name FROM v$database@test_dbl).

    Bu.Name Company_name

    Dboltp.s_org_ext@test_dbl drunk

    INNER JOIN com_unique uusers ON (uusers.bu_id = bu.row_id)

    )

  • Nested cursor in stored procedure.

    Hello.

    I'm trying to extract data from Ref Cursor ON filling by the stored procedure parameter.
    Using the latest version of the ODP.NET (11.2.0.3.0) provider.

    My stored procedure:

    TYPE cursor_type IS REF CURSOR;


    PROCEDURE test_proc (p_recordset to cursor_type) AS

    BEGIN

    OPEN FOR P_recordset
    SELECT 1, 2, CURSOR (SELECT FROM dual 3.4)
    OF the double

    END;
    END test_proc;


    If I remove ' * SLIDER (SELECT 3.4 FROM dual) * "the procedure, everything works fine.
    But when the nested cursor exists in procedure, I'm getting the following exception:


    System.NullReferenceException is produced
    Message = object reference not set to an instance of an object.
    Source = Oracle.DataAccess
    StackTrace:
    at Oracle.DataAccess.Client.OracleDataReader.GetOraDbTypeEx (Int32 i)
    to Oracle.DataAccess.Client.OracleDataReader... ctor (OracleConnection connection, opsDacCtx IntPtr, IntPtr opsSqlCtx, IntPtr opsErrCtx, OpoSqlValCtx [] pOpoSqlValCtx, OpoDacValCtx * pOpoDacValCtx, metadata metadata, Int32 resultCount, CommandBehavior commandBehavior, safeMapping Hashtable, String commandText, Int32 freeOpsSqlCtx, Boolean bFetchSizePropertySet) *.
    at Oracle.DataAccess.Types.OracleRefCursor.GetDataReader (Boolean fillRequest)
    at Oracle.DataAccess.Types.OracleRefCursor.GetDataReader)
    to CursorTester.Program.NestedCursorAsOutParamStoredProc () in

    InnerException:


    My c# code:

    using (OracleConnection conn = new OracleConnection (connString))
    *{*
    OracleCommand command = new OracleCommand();
    command. Connection = conn;
    adCmdTable = System.Data.CommandType.StoredProcedure;
    command.CommandText = "test_proc;

    OracleParameter parameter1 = new OracleParameter();
    "Parameter1". Direction = ParameterDirection.Output;
    "Parameter1". OracleDbType = OracleDbType.RefCursor;

    command. Parameters.Add (parameter1);

    command. Connection.Open ();

    command. ExecuteNonQuery());

    OracleRefCursor r = command. Parameters [0]. Value as OracleRefCursor;

    var reader = r.GetDataReader (); Here the exception is thrown
    *}*

    If I'm changing procedure output parameter signature, to return the value code throws the same exception.


    I am tempted to google about this problem, but impossible to find at least a topic with the same problem (same exception).
    I've seen a few old threads (from 2004-2005), where people declaring that nested cursors are not supported in ODP.NET.
    On the other hand, I can't find any official publication of the latest version ODP.NET, that nested cursors are still not supported.

    I will very grateful, if someone can tell me of sense about this problem. Already stuck on this for a few days.
    Thank you!

    ODP.NET does not support nested cursors.

  • PLS-00355 error when opened the cursor in the procedure

    Hello everyone,

    I have a problen that makes me crazy:

    Whenever I try to compile the following procedure, the error "PLS-00355: table using pl/sql not allowed in this context" occurs but I don't see what the problem is. I hope that the wisdome of the community will help to solve the problem.

    Here is the code:

    CREATE or REPLACE PROCEDURE data_year (study_year in NUMBER) HAVE
    CONSTANT CHAR Sep: = "";
    CURSOR cursor_year (year_of_interest NUMBER) IS
    Select
    BBS_CONDITIONS. COUNTRYNUM as a country,
    BBS_CONDITIONS. STATENUM as State,
    BBS_CONDITIONS. ROUTE road,
    BBS_ROUTES. LATITUDE lat,
    BBS_ROUTES. LONGITUDE as lon,
    BBS_SUMMARY. AUG as Aug,
    BBS_SPECIES. ENGLISH_COMMON_NAME as the name,
    BBS_SPECIES. MIGRATION_TYPE as migtype,
    BBS_SUMMARY. SPECIESTOTAL County,
    BBS_CONDITIONS. MONTH as smonth,
    BBS_CONDITIONS. STARTTIME as starttime,
    BBS_CONDITIONS. ENDTIME as end time,
    BBS_CONDITIONS. AMATURES amatures, as
    BBS_CONDITIONS. ASSISTANT Assistant
    of BBS_SPECIES.
    BBS_ROUTES,
    BBS_SUMMARY,
    BBS_CONDITIONS
    where BBS_ROUTES. ROUTE = BBS_CONDITIONS. ROUTE
    and BBS_ROUTES. STATENUM = BBS_CONDITIONS. STATENUM
    and BBS_ROUTES. COUNTRYNUM = BBS_CONDITIONS. COUNTRYNUM
    and BBS_SPECIES. AUG = BBS_SUMMARY. AUG
    and BBS_CONDITIONS. AN = BBS_SUMMARY. YEAR
    and BBS_CONDITIONS. ROUTE = BBS_SUMMARY. ROUTE
    and BBS_CONDITIONS. STATENUM = BBS_SUMMARY. STATENUM
    and BBS_CONDITIONS. COUNTRYNUM = BBS_SUMMARY. COUNTRYNUM
    and BBS_SPECIES. CLASS_ID = 0
    and BBS_CONDITIONS. AN = year_of_interest
    order by country, State, road, migtype, Aug.
    rec_year cursor_year % ROWTYPE;
    I have NUMBER: = 1;
    TYPE table_year_type IS TABLE OF cursor_year % ROWTYPE;
    table_year table_year_type;
    BEGIN - Beginning of the data_year procedure
    table_year: = table_year();
    OPEN cursor_year (study_year);
    LOOP
    EXTRACT the cursor_year in rec_year;
    EXIT WHEN cursor_year % NOTFOUND;
    table_year. EXTEND (1);
    table_year (i): = rec_year;
    i: = i + 1;
    END LOOP;
    CLOSE Cursor_year;
    DBMS_OUTPUT. Put_line ('country' | sep |) "the State" | Ms | "Route". Ms | "lat". Ms | "lon".
    || Ms | "Aug" | Ms | "name" | Ms | "migtype" | Ms | 'count '. Ms | 'month ' | Ms
    || "starttime" | Ms | "endtime" | Ms | "amatures | Ms | "Wizard");
    BECAUSE me in table_year. FIRST... table_year. LAST LOOP
    DBMS_OUTPUT. Put_line (to_char (table_year (i). Country) | Ms | To_char (table_year (i). State) |
    Ms | To_char (table_year (i) .route) | Ms | To_char (table_year (i). LAT) | Ms |
    To_char (table_year (i). LON) | Ms | To_char (table_year (i). AUG) | Ms |
    table_year (i) .name | Ms | To_char (table_year (i) .migtype). Ms |
    To_char (table_year (i). Count). Ms | To_char (table_year (i) .smonth). Ms |
    To_char (table_year (i). StartTime) | Ms | To_char (table_year (i). EndTime) | Ms |
    To_char (table_year (i). RPID) | Ms | To_char (table_year (i). Assistant));
    END LOOP;
    END; -End of the data_year procedure
    /

    Thanks in advance, TC

    Give a line number? I wonder if it might be

    table_year: = table_year();

    that is the origin of the problem. Try to remove and see.

    Better yet, change your code to

    ...
       TYPE table_year_type IS TABLE OF cursor_year%ROWTYPE INDEX BY BINARY_INTEGER;
    
       table_year     table_year_type;
    BEGIN         
    
        OPEN cursor_year (study_year);
        FETCH cursor_year BULK COLLECT INTO table_year;
        CLOSE cursor_year;
    ...
    

    Published by: Dave hemming on November 21, 2008 09:51

  • Calling a procedure that returns a cursor in a procedure

    Hello
    I have two stored procedures. They both return a cursor as output variables. However, I have another stored procedure that calls these procedures and return their results once again an output variable. I know that sounds strange to want to do something like this, but how can I do this?

    Mikhail says:

    My first procedure returns a cursor. But the cursor is opened on one condition. Like, if PARAM1 = 1 THEN OPEN cursor_1 to SELECT... OTHERWISE, OPEN CURSOR_1 TO SELECT... And the second slider has the same structure. The thing is in the two procedures if I declare that a single CURSOR_1 IN OUT parameter that the procedure will not work. So in both entities, I have two variables IN OUT SYS_REFCURSOR: c1 and c2. Then, in the third procedure I first call the first procedure, then the second. How can I write my third procedure in order to obtain the result two procedures United?

    Why the appellant (3rd procedure) need to have 2 ref Cursor? How will the appellant to "unite" the sliders?

    The actual data, a power of work must be done inside sliders. Not in PL/SQL or other languages. The SQL language is a very powerful and flexible language.

    So if the SQL 2 data sets (or more) must be "United", then you should not use the 3rd procedure and PL/SQL code to do. Should use you 2 sliders.

    You should watch this by using SQL only. The 2 sets of data can be merged, joined, union'ed. You can determine the intersection. You can determine the difference (with a negative sign). It can be rotated. It can be aggregated. It can be cube' ed. Etc.

    This SQL will then be used as a single slider and a unique reference cursor handle will be used to consume the output of the cursor.

    The basic rule to develop Oracle applications is simple. Optimize SQL. Minimize the PL/SQL.

    Use the SQL language to the data of the crisis. No PL/SQL.

  • How to filter data in cursors within the procedure

    Hello

    Yesterday, I tried all night, but couldn't do it.

    I know that is incomplete, I just want to know how to filter the data based on the setting in

    Basically, here I want to get only the records that match the id_fichier


    create or replace PROCEDURE clearing_details (p_file_id in varchar2)
    IS
    strStatusCode VARCHAR2 (6);
    CURSOR PD1 IS
    SELECT COUNTRY_CODE, EOD_MARK OF LINK_STATUS WHERE FILE_ID is p_file_id


    Can someone help me on this please:


    Thanks for reading.

    Does do the same if you run the query itself in SQL * Plus with the same value you pass as a parameter?

    Without seeing your data and which parameter you're passing, we will fight help more as the concept itself works great as you have been demonstrated.

  • Using of the dynamic SQL and the cursor in a procedure

    Here is the procedure:
    create or replace
    Procedure type_paiement_total
    is
    
        cursor xbtable is select table_name from user_tables where table_name like 'XB%';
        n_table user_tables.table_name%type;
        req     varchar2(256);
        journal varchar2(2);
        mois varchar2(2);
        an varchar2(2);
      begin
        for n_table in xbtable
        loop
          execute immediate 'insert into xx_jk_xb (
          clie_code,journal, periode,origine, xb_ecri,xb_libe  ,dos_code,xb_debi,xb_cred,xb_term
    )
    select c.code,  
    substr(:1,3,2),
    substr(:1,7,2)||substr(:1,5,2)||,
    :1,  
    xb.ecri,  
    xb.libe,  
    d.code,
    xb.debi,
    xb.cred,
    xb.terme
    from                      
    '||n_table.table_name ||' xb,
    dossier d,                      
    client c                    
    where xb.cmpt=''4111''                    
    and xb.doss  =d.code                    
    and c.code   =d.clie
    and c.role=''1''' using n_table.table_name;
          execute immediate 'insert into xx_jk_logxb (recnum,xb_ref,trsf) values (seq_logmreg.nextval,:1,''OK'')' using n_table.table_name;
          commit;
          fetch xbtable into n_table;
        end loop;
      end;
    What he does (or what I intend to do)
    take the datas of a whole bunch of pictures and put them in the "XX_JK_XB" table and make a log of the tables covered in xx_jk_logxb give just the source table and the status (OK).
    Now when I run the procedure I get a "missing expression" th ' immediate «insert into xx_jk...»» »

    I just can't tell what is the problem here.

    clues?

    Seems to me that you are wrong assuming that the binding can be done by name and no position when you use immediate enforcement.

    Example:

    SQL> create table foo_tab( c1 varchar2(10), n1 number );
    
    Table created.
    
    SQL>
    SQL> begin
      2          for i in 1..10
      3          loop
      4                  execute immediate 'insert into foo_tab values( to_char(:1), :1 )' using i;
      5          end loop;
      6          commit;
      7  end;
      8  /
    begin
    *
    ERROR at line 1:
    ORA-01008: not all variables bound
    ORA-06512: at line 4
    
    SQL>
    SQL>
    SQL> begin
      2          for i in 1..10
      3          loop
      4                  execute immediate 'insert into foo_tab values( to_char(:1), :1 )' using i,i;
      5          end loop;
      6          commit;
      7  end;
      8  /
    
    PL/SQL procedure successfully completed.
    
    SQL>
    

    As you can see, 1 PL/SQL block attempts to re - use bind variable: 1 new - and only link once.

    Fact does not work like that - you must link it again. Binding is done by bind - 1 position = 1 to the help of var, 2nd = 2nd bind using var, etc.. Name of the connection variable used is irrelevant and not unique.

  • Call a member function from a cursor in a procedure

    Hello people

    I'm a newbie in the process of learning of 10 G and oracle. My question is:

    I created a type called row_po and set a member function getCost() that returns the total cost of the order with headings like the nested table, which I intend to call from a procedure. In the procedure my SELECT returns more than one record, and that's why I need to use a cursor. For each record, I've got display the order_no, quantity, and the order_cost (qty, and order_cost are part of a nested table headings). I am able to access the order_no and quantity, but do not know how to call the member function to get the order_cost. Here are my steps:

    CREATE OR REPLACE PROCEDURE get_podet (part_num number)
    AS
    CURSOR c2 is
    SELECT *.
    OF po, TABLE (in. LineItemList_nestab) tab_po L
    WHERE L.PartNo = part_num;
    BEGIN
    TO crec looped c2
    DBMS_OUTPUT. Put_line (' ORDER NUMBER: ' | crec.) PONo);
    DBMS_OUTPUT. Put_line (' LINE QTY: ' | crec.) Qty);
    {color: #ff0000} * DBMS_OUTPUT. PUT_LINE (' ORDER VALUE: ' |) ''); -order_cost, which must be returned by the member function I mentioned-*.
    {color} END LOOP;
    EXCEPTION
    WHILE OTHERS THEN
    DBMS_OUTPUT. Put_line ('Failed' |) "SQLCODE: ' |" SQLCODE);
    DBMS_OUTPUT. PUT_LINE ('SQL ERROR MESSAGE' |) SQLERRM);
    END;
    /

    The red line is where I want to call my function getCost() which is a member of the tab_po in. as stated in my SELECTION.

    All thoughts were highly appreciated.

    Thanks and greetings

    It's always tricky with objects (or so I think...)

    Modify the query in your procedure:

    SELECT treat (value (po) as row_po).getCost() tot_cost
         , po.*
         , l.*
    FROM tab_po po, TABLE (po.LineItemList_nestab) L
    

    This would make the function:

    CREATE OR REPLACE PROCEDURE get_podet(part_num in number)
    AS
    CURSOR c2 is
    SELECT treat (value (po) as row_po).getCost() tot_cost
         , po.*
         , l.*
    FROM tab_po po, TABLE (po.LineItemList_nestab) L
    WHERE L.PartNo = part_num;
    BEGIN
    FOR crec in c2 LOOP
    DBMS_OUTPUT.PUT_LINE('ORDER NUMBER: ' || crec.PONo);
    DBMS_OUTPUT.PUT_LINE('LINE QTY: ' || crec.Qty);
    DBMS_OUTPUT.PUT_LINE('ORDER VALUE: ' ||crec.tot_cost
    ); -- order_cost which should be returned from the member function i've mentioned --
    END LOOP;
    EXCEPTION
    WHEN OTHERS THEN
    DBMS_OUTPUT.PUT_LINE('Failed' || 'SQLCODE: ' || SQLCODE);
    DBMS_OUTPUT.PUT_LINE('SQL ERROR MESSAGE ' || SQLERRM);
    END;
    

    Published by: Alex Nuijten on January 13, 2009 15:29

  • How to perform this procedure. .pls help with example

    / * It displays a warning * /.
    -How to remove this warning


    CREATE PROCEDURE EMP_TITLE_GENERATOR (EMP_GENDER IN (1) TANK, EMP_TITLE OUT VARCHAR2)
    IS
    BEGIN
    EMP_TITLE: = Decode(EMP_GENDER,'M','Mr','F','Ms','INVALID');
    EXCEPTION
    WHILE OTHERS THEN
    DBMS_OUTPUT. PUT_LINE (SQLERRM);
    END;

    Published by: 923746 on April 18, 2012 19:58

    Published by: 923746 on April 18, 2012 19:59
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining options
    
    SQL> CREATE PROCEDURE EMP_TITLE_GENERATOR (EMP_GENDER IN VARCHAR2,EMP_TITLE OUT VARCHAR2)
      2  IS
      3  begin
      4  select DECODE(EMP_GENDER,'M','Mr','F','Ms','INVALID') into emp_title from dual;
      5  EXCEPTION
      6  WHEN OTHERS THEN
      7  dbms_output.put_line(sqlerrm);
      8  END;
      9  /
    
    Procedure created.
    
    SQL> set serveroutput on
    SQL> DECLARE
      2    EMP_GENDER VARCHAR2(200);
      3    EMP_TITLE VARCHAR2(200);
      4  BEGIN
      5    EMP_GENDER := 'F';
      6
      7    EMP_TITLE_GENERATOR(
      8      EMP_GENDER => EMP_GENDER,
      9      EMP_TITLE => EMP_TITLE
     10    );
     11    DBMS_OUTPUT.PUT_LINE('EMP_TITLE = ' || EMP_GENDER);
     12    DBMS_OUTPUT.PUT_LINE('EMP_TITLE = ' || EMP_TITLE);
     13  END;
     14  /
    EMP_TITLE = F
    EMP_TITLE = Ms
    
    PL/SQL procedure successfully completed.
    
    SQL> 
    
  • Skype is imported pls do something

    I own this 701coz Skype but? Please do something to Skype thanks

    need for Skype on nokia 701thanks

  • pls-00323: subprogram or cursor "Dec" is declared in the package specification

    Hello

    How to fix the error below
    pls-00323: subprogram or cursor 'Drec' is declared in package specification and must be defined in the package body
    in fact, my code is here

    Spec
    create or replace package x is
    
      type typ_x277  is record (
      rcncd fin_rcn_grp_mas.rcn_cd%type,
      icode item_master.item_code%type,
      idesc item_master.short_desc%type,
      ob_qty Number,
      rcpt_qty number,
      issue_qty number,
      incr_qty number,
      Rate number,
      incr_value number);
      
      type ref_x277 is ref cursor return typ_x277; 
      
      Procedure drec(x277_rec in out ref_x277,rcncd varchar,fdate date,tdate date);
    
    end x;
    body
    create or replace package body x is
    
    Procedure drec(x277_rec in out ref_x277,rcncd varchar2,fdate date,tdate date) as
    Begin
    open x277_rec for 
    Select rcn_cd,item_code,short_desc,op,rcpt,issu,incrqty,month_rate,incrqty*month_rate incrvalue
    from(
    Select rcn_cd,item_code,short_desc,find_item_opening(item_code,fdate) op,rcpt,issu,(find_item_opening(item_code,fdate)+rcpt) - issu incrqty,month_rate
    from(
    select rcn_cd,a.item_code,short_desc,month_rate,sum(nvl(mrir_qty,0)) Rcpt,sum(nvl(issue_qty,0)) issu
    from(
      select item_key,b.rcn_cd,mrir_ccn(a.po_no,a.item_code) as ccn,a.item_code,sum(a.quantity) as mrir_qty, null issue_qty 
        from kar a,fin b
        where trunc(a.document_date,'DD') between fdate and tdate and
              b.rcn_cd=rcncd and
              mrir_ccn(a.po_no,a.item_code)=b.ccn_cd and
              nvl(a.quantity,0) > 0 and
              a.card_code = '50'
        group by item_key,b.rcn_cd,mrir_ccn(a.po_no,a.item_code),a.item_code
        having sum(a.quantity) > 0
    union    
         select item_key,b.rcn_cd,a.ccn,a.item_code,null mrir_qty, sum(a.quantity) as issue_qty 
        from kardex a,fin_rcn_grp_mas b
        where trunc(a.document_date,'DD') between fdate and tdate and
              b.rcn_cd=rcncd and
              a.ccn=b.ccn_cd and
              nvl(a.quantity,0) > 0 and
              a.card_code in ('70','71','72')
        group by item_key,b.rcn_cd,a.ccn,a.item_code)a,
    item_master b,item_quantity c
    where a.item_code = b.item_code
    and a.item_key = b.item_key
    and a.item_key = c.item_key
    and b.item_key = c.item_key
    group by rcn_cd,a.item_code,short_desc,month_rate
    having sum(nvl(mrir_qty,0)) > 0
    order by rcpt desc,a.item_code));
    end;
    
    
    end x277;
    my spec is perfectly compiled where the body becomes the error said above.

    How to recover this question.

    Iqbal

    In spec you have this

    Procedure gillison (x277_rec in ref_x277, rcncd varchar, date, date of tdate fdate);

    In the body, you have this

    Procedure gillison (x277_rec in ref_x277, rcncd varchar2, date, date of tdate fdate) as

    for rcncd in spec its VARCHAR and the body its VARCHAR2. Change both to VARCHAR2

  • Confused with cursors in procedures of the Oracle

    Hello

    I'm new to PLSQL programming, learning every day.
    I have a request here

    I read that if we use explicit cursor in the procedure, then we need to open it, extract it, and then close it, which i did a few examples.

    Below is a procedure that is nothing like opening the cursor, extracting data from the cursor - etc then how it works?

    create or replace procedure show_empnos (p_deptno number) is
    cursor cur_emps is
    Select empno
    WCP
    where deptno = p_deptno
    order by empno;
    Start
    for e in cur_emps
    loop
    dbms_output.put_line ('EmpNo: ' | to_char (e.empno, 'fm99999'));
    end loop;
    end;

    Please notify.

    user10503747 wrote:
    Hello

    I'm new to PLSQL programming, learning every day.
    I have a request here

    I read that if we use explicit cursor in the procedure, then we need to open it, extract it, and then close it, which i did a few examples.

    Below is a procedure that is nothing like opening the cursor, extracting data from the cursor - etc then how it works?

    create or replace procedure show_empnos (p_deptno number) is
    cursor cur_emps is
    Select empno
    WCP
    where deptno = p_deptno
    order by empno;
    Start
    for e in cur_emps
    loop
    dbms_output.put_line ('EmpNo: ' | to_char (e.empno, 'fm99999'));
    end loop;
    end;

    Please notify.

    Education FOR implements open, fetch and close automatically as part of its build.

  • Newbie - how to import the package, procedures, etc.?

    I used the "data export", the computer of the developer, expoty tables, export procedures, export Packages, etc. in a file
    SQL Developer.

    In Sql Developer, how to import tables, import procedures, import packages on my computer "REAL LIVE"?

    I want to copy the Package, the copy procedure, etc. 'computing Developer' to computer "LIVE REAL DATA?


    TIA
    Steve42

    If you have access to 2 databases of your sqldev client (and therefore have connections put in place for both of them), just run the export file obtained from the DB dev as a script (F5), using the connection to the production DB (drop-down menu at the top right).

    Have fun
    K.

  • CURSOR variable in

    Trawling back through messages, but have not seen a response.

    I want to move a collection to a procedure and do something with this collection.  The procedure can be called from another proc or a c# program.

    Heres my demo

    -create table test and place 2 records in

    create table t_curtest (col1, col2 number number)

    insert into t_curtest

    values (1,1);

    insert into t_curtest

    values (2,2);

    commit;

    create package specification

    SQL > create or replace package pkg_curtest

    2 AS

    3 TYPE t_curtype IS TABLE OF t_curtest % ROWTYPE;

    4 procedure prc_curtest

    5 (v_curvar IN t_curtype);

    6 END;

    7

    8

    9.

    Package created.

    SQL >

    create the package body that takes in a slider and bulk collect into a table

    SQL > create or replace package body pkg_curtest

    2 EAST

    3 procedure prc_curtest

    4 (v_curvar IN t_curtype)

    5 EAST

    6 BEGIN

    FORALL i in 1 7... v_curvar. Count

    8

    9 INSERT INTO t_curtest

    10 VALUES v_curvar (i);

    11

    12 COMMIT;

    13

    14 END;

    15 END;

    16

    17.

    Package body created.

    SQL >

    Now try and move a cursor in the further procedure and we get incorrect types.  what I am doing wrong?  It's whole approach?

    SQL > create or replace procedure call_curtest

    2 AS

    3 cursor c1 is select * from t_curtest; -same table we'll insert to so we know its good

    4 BEGIN

    5. place the cursor in a procedure call.

    6 pkg_curtest.prc_curtest (c1);

    7 END;

    8.

    CAUTION: Procedure created with compilation errors.

    SQL > show errors

    Errors in PROCEDURE CALL_CURTEST:

    LINE/COL ERROR

    -------- -----------------------------------------------------------------

    6/5 PL/SQL: statement ignored

    6/5 PLS-00306: wrong number or types of arguments in the call to

    'PRC_CURTEST '.

    This final procedure call, you declare your cursor of the same type

    create or replace procedure call_curtest
      2  AS
      3  cursor c1 is select * from t_curtest; -- same table as we're inserting to so we know its good
      4  BEGIN
      5    -- pass cursor into procedure call.
      6      pkg_curtest.prc_curtest(c1);
      7  END;
    

    Try declaring the cursor first as type pkg_curtest. t_curtype

    FYI: Just noticed your comment - this is where your assumption is incorrect:

    -same table we'll insert to so we know its good

    You need not even as a TABLE. you need the same type...

  • function work at the same time that the work can also do procedure...

    pls tel me major diff b/w cursor implicit vs explicit cursor and function procedure vs.

    Published by: 955345 on August 27, 2012 22:11

    Published by: Rousseau on August 28, 2012 11:08

    Rousseau wrote:
    k k bt

    What does that mean?

    function to do some work at the same time that work also can make procedure... Why work

    Function has the ability to be used in SQL, but cannot be a procedure.

    Basically, I use the procedure for transactional operation and function for Non-transactional operation. For example, if I have to update a table I would use a procedure to wrap my update statement. And if I have to do some calculations or run some select and return a result of Ref Cursor I would use a function.

    In addition to the technical restrictions of function and procedure its more the choices make us.

Maybe you are looking for

  • My iMac 27 "is VERY slow

    I ran Etrecheck: I don't understand any of this, can someone take a look and tell me if I have problems with my iMac? EtreCheck version: 2.9.12 (265) Report generated 2016-06-17 16:53:13 Download EtreCheck from https://etrecheck.com Time 01:48 Perfor

  • How can I download mp3 to blogsites and transfer files to the flash drive. ?

    Hello I visit various blogsites where music albums are available for download in mp3 format. When I download an album where he's going. ?? Most of the files must also be extracted using WIN. RAR in mp3 format. (I do now with my windows pc) How this c

  • My friends iPad 3 cannot upgrade to iOS 9, stuck on iOS 8

    O Hai guys my friends iPad der 3 stuck on iOS 8 and it cannot upgrade to iOS 9.2. Please halp and give clues to meh!

  • Droid Maxx Wireless load?

    I heard that the droid wireless charger will make a sound of snoring in use. Is it true if is it so the phone or the charger?

  • Windows automatic update does not install.

    The last Windows Update Auto fails to install. I am running Windows 7 it. For these last two days the automatic Windows Update has downloaded an update when I stopped for the night. The next morning at startup it try to install the update and sits th