Declaring a cursor....newbie

Here ...
I am unable to declare sampleCursor
PROCEDURE MY_PROC_GET(
dataCursor OUT RpTypes.RefCursor, /*This is fine */
operationType IN varchar
AS
sampleCursor RPTYPES.RefCursor%TYPE;
/*error here same for RpTypes.RefCursor */
BEGIN
Error:
Error(9,14): PLS-00206: %TYPE must be applied to a variable, column, field or attribute, not to "RPTYPES.REFCURSOR"
Error(9,14): PL/SQL: Item ignored

Hi,
Worked with
sampleCursor RpTypes.RefCursor;
tx

Similar Messages

  • Can we declare a Cursor in Package Specs?

    Dear buddies
    Can I Declare a Cursor in Package Specs so that I can call that cursor and use its data in some procedures and functions of package. Otherwise I've to write that cursor for every sub-program of a package which I don't feel a smart way to accomplish the job.

    Hi,
    here is a short example with the whole way down. Maybe the concept is getting clearer with this:
    first of all, if you do not have the table emp, here the DDL for this example.
    Be carefull, works only for german clients because of the names of months, sorry for that.
    CREATE TABLE EMP
    (EMPNO NUMBER(4) NOT NULL,
    ENAME VARCHAR2(10),
    JOB VARCHAR2(9),
    MGR NUMBER(4),
    HIREDATE DATE,
    SAL NUMBER(7, 2),
    COMM NUMBER(7, 2),
    DEPTNO NUMBER(2));
    set echo on
    INSERT INTO EMP VALUES
    (7369, 'SMITH', 'CLERK', 7902,
    TO_DATE('17-DEZ-1980', 'DD-MON-YYYY'), 800, NULL, 20);
    INSERT INTO EMP VALUES
    (7499, 'ALLEN', 'SALESMAN', 7698,
    TO_DATE('20-FEB-1981', 'DD-MON-YYYY'), 1600, 300, 30);
    INSERT INTO EMP VALUES
    (7521, 'WARD', 'SALESMAN', 7698,
    TO_DATE('22-FEB-1981', 'DD-MON-YYYY'), 1250, 500, 30);
    INSERT INTO EMP VALUES
    (7566, 'JONES', 'MANAGER', 7839,
    TO_DATE('2-APR-1981', 'DD-MON-YYYY'), 2975, NULL, 20);
    INSERT INTO EMP VALUES
    (7654, 'MARTIN', 'SALESMAN', 7698,
    TO_DATE('28-SEP-1981', 'DD-MON-YYYY'), 1250, 1400, 30);
    INSERT INTO EMP VALUES
    (7698, 'BLAKE', 'MANAGER', 7839,
    TO_DATE('1-MAI-1981', 'DD-MON-YYYY'), 2850, NULL, 30);
    INSERT INTO EMP VALUES
    (7782, 'CLARK', 'MANAGER', 7839,
    TO_DATE('9-JUN-1981', 'DD-MON-YYYY'), 2450, NULL, 10);
    INSERT INTO EMP VALUES
    (7788, 'SCOTT', 'ANALYST', 7566,
    TO_DATE('09-DEZ-1982', 'DD-MON-YYYY'), 3000, NULL, 20);
    INSERT INTO EMP VALUES
    (7839, 'KING', 'PRESIDENT', NULL,
    TO_DATE('17-NOV-1981', 'DD-MON-YYYY'), 5000, NULL, 10);
    INSERT INTO EMP VALUES
    (7844, 'TURNER', 'SALESMAN', 7698,
    TO_DATE('8-SEP-1981', 'DD-MON-YYYY'), 1500, 0, 30);
    INSERT INTO EMP VALUES
    (7876, 'ADAMS', 'CLERK', 7788,
    TO_DATE('12-JAN-1983', 'DD-MON-YYYY'), 1100, NULL, 20);
    INSERT INTO EMP VALUES
    (7900, 'JAMES', 'CLERK', 7698,
    TO_DATE('3-DEZ-1981', 'DD-MON-YYYY'), 950, NULL, 30);
    INSERT INTO EMP VALUES
    (7902, 'FORD', 'ANALYST', 7566,
    TO_DATE('3-DEZ-1981', 'DD-MON-YYYY'), 3000, NULL, 20);
    INSERT INTO EMP VALUES
    (7934, 'MILLER', 'CLERK', 7782,
    TO_DATE('23-JAN-1982', 'DD-MON-YYYY'), 1300, NULL, 10);2. Package Spec:
    create or replace
    package test_cursor as
      --Type for the returncode of the function
      TYPE typ_emp IS TABLE OF emp%rowtype;
      --Array for fetching, of course also possible in the body
      t_emp typ_emp;
      --function wich returns the array from fetching the cursor
      function get_emp return typ_emp;
      --function for manupilation data retrieved by the function
      PROCEDURE man_emp;
    end test_cursor;3. Package Body
    create or replace
    package body test_cursor as
      FUNCTION get_emp RETURN typ_emp AS
      cursor c_emp is select * from emp;
      BEGIN
        open c_emp;
        fetch c_emp BULK COLLECT INTO t_emp;
        CLOSE c_emp;
        --t_emp returns the whole table set from emp
        return t_emp;
      end get_emp;
      PROCEDURE man_emp AS
      --just for not confusing names, is the same as t_emp of course
      v_emp_array typ_emp;
      BEGIN
        --call the function and retrieve the whole data set
        v_emp_array := get_emp;
        --now manipulate the data, in this case just write the names to the calling client
        FOR rec IN v_emp_array.FIRST .. v_emp_array.LAST
        loop
          dbms_output.put_line(v_emp_array(rec).ename);
        end loop;
      end man_emp;
    end test_cursor;4. Calling the procedure
    SET serveroutput ON
    exec test_cursor.man_emp;5. And this is the result:
    anonymer Block abgeschlossen
    SMITH
    ALLEN
    WARD
    JONES
    MARTIN
    BLAKE
    CLARK
    SCOTT
    KING
    TURNER
    ADAMS
    JAMES
    FORD
    MILLERPlease be aware, this is just for demonstration purpose, of course it makes no sense to display the names this way. But how to call a funktion returning arrays with datasets from fetching cursors is shown here.
    Hth
    Joerg

  • Declaring a cursor

    hi all,
    is it possible to declare a cursor like this ..???
    declare
    cursor is select ab.col1,cd.col2 from
    (select a.col1,b.col2
    from a,b
    conditions)ab
    (select c.col1,d.col2...
    from c,d
    conditions..)cd
    i am getting the following error
    PL/SQL: ORA-00923: FROM keyword not found where expected

    Plenty of syntactical error in your cursor declaration. It should be like this ->
    cursor c1
    is
      select ab.col1,
             cd.col2
      from (
             select a.col1,
                    b.col2
             from a,b
             where conditions
           ) ab,
            select c.col1,
                   d.col2...
            from c,d
            where conditions..) cd
      where ab.cond1 = cd.cond1;Regards.
    Satyaki De.

  • Declaring a cursor in an Anonymous Block

    How do I declare a cursor in an Anonymous Block? I've looked in several sources and haven't found anything that explains this.
    Does anyone have a link to where this would be explained?
    Thanks

    Depends on whether you're talking about an explicit or an implicit cursor, but it's basically the same way you declare either in a non-anonymous block, i.e.
    DECLARE
      CURSOR cursor_name IS ...
    BEGIN
    END;or
    BEGIN
      FOR x IN (SELECT ... )
      LOOP
      END LOOP;
    END;Justin

  • Procedures declaring a cursor

    Hi ,
    I have the following I am declaring a cursor within a procedure before a BEGIN - How can i decalre the cursor inside the the procedure
    as this is not correct below ?
    Something like so :
    PROCEDURE abc(
    table_name IN VARCHAR2)
    IS
    --v_sql varchar2(4000); 
    DECLARE
    temp VARCHAR(20);
    CURSOR ...................IS
    BEGIN
    using the cursor
    END
    Edited by: user618557 on Feb 25, 2009 3:47 AM

    user618557 wrote:
    Thanks that worked ...That's good.
    As to your new question; I have no idea as to what you are trying to do.
    Ever seen this?
    SQL> select dbms_metadata.get_ddl ('TABLE', 'EMP', 'SCOTT') from dual
    DBMS_METADATA.GET_DDL('TABLE','EMP','SCOTT')                                   
      CREATE TABLE "SCOTT"."EMP"                                                   
       (     "EMPNO" NUMBER(4,0) NOT NULL ENABLE,                                      
         "ENAME" VARCHAR2(10),                                                         
         "JOB" VARCHAR2(9),                                                            
         "MGR" NUMBER(4,0),                                                            
         "HIREDATE" DATE,                                                              
         "SAL" NUMBER(7,2),                                                            
         "COMM" NUMBER(7,2),                                                           
         "DEPTNO" NUMBER(2,0)                                                          
       ) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING          
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645        
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)             
      TABLESPACE "USERS"                                                           
    1 row selected.Regards
    Peter

  • How to declare a cursor with stored proc?

    Hi All,
    Can we declare a cursor with stored proc?
    For Example -
    CREATE PROCEDURE DDL_proc() LANGUAGE SQLSCRIPT AS
        CURSOR c_cursor1 (v_isbn VARCHAR(20)) FOR CALL SYS.GET_OBJECT_DEFINITION(<SCHEMA_NAME>, <TABLE_NAME>).;
         BEGIN
              FOR cur_row as c_cursor1 DO
              END FOR;
         END;
    Could you please have a look on the same?
    Thank you,
    Vijeesh

    Oracle PL/SQL also has a select into statement which is described in the same manual the link takes you to part of.
    select column_list
    into variable_list
    from table(s)
    where conditions
    The PL/SQL Users Guide is something you are going to want to have gone over cover to cover before you start converting because so that you make the best choices for how to rewrite the code: select into, explicit cursor, implicit cursor, for loop, simple loop, while loop, collections,bulk load, etc ....
    HTH -- Mark D Powell --

  • Declaration of cursor type in package/sp

    Hi,
    I'm using package with sp that using cursor like below:
    --#1============================ PACKAGE
    {PACKAGE                                ORA_PK_TR2 AS
      Type CURS_01  IS REF CURSOR;  --- return RYBB.T_COLLECT%rowtype;
      Procedure ORA_SP_CUST (EXP_DATE IN date,                    
    END
    --#2============================  BODY
    create or replace
    PACKAGE BODY                           ORA_PK_TR2  as
         Procedure ORA_SP_CUST (EXP_DATE IN date,                    
                                          open_CURS_01 OUT CURS_01 )   IS
    BEGIN
    SQL_string = '(select * from RYBB.T_COLLECT where col='||EXP_DATE)'
    OPEN open_CURS_01 FOR  SQL_STRING;
    END;
    --#3=============================  RUN_PORTION
    DECLARE
      EXP_DATE DATE;
    OPEN_CURS_01 RYBB.ORA_PK_TR2.CURS_01;
      TYPE_IN RYBB.T_COLLECT%ROWTYPE;       --/***** <==== need to move into package
    BEGIN
    EXP_DATE := '10-sep-10';
    RYBB.ORA_PK_TR2.ORA_SP_CUST(
        EXP_DATE => EXP_DATE,
       OPEN_CURS_01 => OPEN_CURS_01
    LOOP
        FETCH open_CURS_01 INTO TYPE_IN;
        EXIT WHEN open_CURS_01%NOTFOUND;
        DBMS_OUTPUT.PUT_LINE(TYPE_IN.COL1||' '||TYPE_IN.COL2);    --/ for sample
    END LOOP; 
    END;}
    I need to put TYPE_IN declation for cursor inside the package, so user who will run this pack/sp won't deal with this structure. How I can do this,
    I tried to use <return RYBB.T_COLLECT%rowtype;> in package but then I get :
    Error(122,6): PLS-00455: cursor 'open_CURS_01' cannot be used in dynamic SQL OPEN statement.
    Not sure can I put it somehow into the BODY and make it available for user ?
    Appreciate you help.
    BEst
    Trent
    Edited by: trento on Sep 13, 2010 2:36 PM

    --#1============================ PACKAGE
    PACKAGE ORA_PK_TR2 AS
    Type CURS_01 IS REF CURSOR; --- return RYBB.T_COLLECT%rowtype;
    Type CURS_01_TYP IS RYBB.T_COLLECT%rowtype;
    --#3============================= RUN_PORTION
    DECLARE
    EXP_DATE DATE;
    OPEN_CURS_01 RYBB.ORA_PK_TR2.CURS_01;
    TYPE_IN RYBB.ORA_PK_TR2.CURS_01_TYP;
    BEGIN
    Difficult to read, don't you think?
    Try use the tags B-)
    Your code has other issues and (as shown here) won't compile. If you have a working solution, why not paste that instead?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Declaring private cursors in package header

    Hi.
    Im tunning a PLSQL package , and im having the following doubt.
    This package has alot of cursors declared in the package header, but the cursors are private. (called within the package only)
    Could the public functions from the package have a loss of performance by using those cursors? (should the private cursors be declared within the functions or at least inside package body?)
    Im kind of new with plsql, so please bare with me :) .
    Cheers.

    there's no performance loss.
    however, unless the cursors are to be accessible outside the package (which is what happens when they are declared in the spec (not header)), then there's no benefit either. if they are truely meant to be private, then you can remove them from the spec. and if you're wrong, and they are called from elsewhere, you'll find out soon enough.

  • Does Declare Dynamic Cursor Support with Order Clause?

    Given a dynamic cursor like
         declare CUR_10 dynamic cursor for SQLSA;
         prepare SQLSA from :ls_SQL;
         open dynamic CUR_10;
         do while TRUE
              fetch CUR_10 into :ls_var1, :ls_var2
         loop
    where ls_SQL is "select COL1, COL2 from TABLE_A order by COL2 desc"
    can I fetch values in the exact DESCENDING order of COL2?

    Hello Ronald,
    Values will be fetched in the way you SQL statement has been defined for your dynamic cursor, so in the descending order.
    I've tested your code with an Oracle connection and it works perfectly.
    Just ensure to add a condition to your DO WHILE statement when the resultset is exhausted:
    DO WHILE TRUE AND SQLCA.SQLCode <> 100
    Kind regards,
    Jacob

  • Looping through a cursor (newbie)

    I am trying to construct a dynamic insert statement. I am retrieving (using a select) the column names from one of my tables into a cursor. I would now like to loop through the cursor and extract the column names. Is there anyway to loop through the cursor like you can normally do as below:
    for i = 0 to cursor%rowcount
    tempstring = tempstring + ',' + cursor.i; (something along these lines)
    end for
    and then do 'insert into tablename (' || tempstring
    Am I making sense?

    There are several methods to process cursors and you can easily find them
    here.
    http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96624/01_oview.htm#740
    http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96624/06_ora.htm#36656
    And before trying to use dynamic sql it would be better to think would you really
    need it...
    Rgds.

  • Error while declaring cursor

    Hi all,when i am trying to declare a cursor in a procedure i am getting errors.Kindly correct me where i am going wrong
      1  CREATE OR REPLACE PROCEDURE xxc_lc_rcv_interface_prc IS
      2      v_a    NUMBER;
      3      v_b    NUMBER;
      4      v_c    NUMBER;
      5      v_d    NUMBER;
      6      v_e    NUMBER;
      7      v_f    NUMBER;
      8      v_g    NUMBER;
      9   CURSOR rcv_interface_cur
    10   IS
    11   SELECT shipment_header_id INTO v_c
    12   FROM RCV_SHIPMENT_HEADERS
    13   WHERE SHIPMENT_NUM = 'NOV1124';
    14   SELECT shipment_line_id INTO v_d
    15   FROM RCV_SHIPMENT_LINES
    16   WHERE SHIPMENT_HEADER_ID = v_c;
    17   BEGIN
    18     SELECT rcv_headers_interface_s.nextval INTO v_a FROM dual ;
    19     SELECT rcv_interface_group_s.nextval INTO v_b FROM dual;
    20     SELECT rcv_headers_interface_s.currval INTO v_e FROM dual ;
    21     SELECT rcv_interface_groups_s.currval  INTO v_f FROM dual;
    22     SELECT rcv_transactions_interface_s.nextval INTO v_g FROM dual;
    23  BEGIN
    24  INSERT INTO rcv_headers_interface
    25  (
    26  HEADER_INTERFACE_ID,
    27  GROUP_ID,
    28  PROCESSING_STATUS_CODE,
    29  RECEIPT_SOURCE_CODE,
    30  TRANSACTION_TYPE,
    31  AUTO_TRANSACT_CODE,
    32  LAST_UPDATE_DATE,
    33  LAST_UPDATE_LOGIN,
    34  LAST_UPDATED_BY,
    35  CREATION_DATE,
    36  CREATED_BY,
    37  VALIDATION_FLAG,
    38  COMMENTS,
    39  SHIPMENT_NUM,
    40  FROM_ORGANIZATION_ID,
    41  SHIP_TO_ORGANIZATION_ID,
    42  EXPECTED_RECEIPT_DATE
    43  --RECEIPT_HEADER_ID
    44  )
    45  VALUES
    46   (v_a,                                         --Header Interface ID
    47   v_b,                                          --Group ID
    48   'PENDING',                                    --Processing Status Code
    49   'INVENTORY',                                  --Receipt source Code
    50   'RECEIVE',                                    --Transaction Type
    51   'DELIVER'  ,                                   --AUT Transact Code
    52   sysdate,                                       --last update date
    53   1053,                                         --last updated by
    54   1053,                                        --Last Update Login
    55   sysdate,                                      --creation date
    56   1053,                                         --created by
    57   'Y',                                          --Validation Flag
    58   'Receiving Through Interface',                --Comments
    59   'NOV1124' ,                                --Shipment Number
    60   81,                                           --From Org
    61   82,                                           --To org
    62   sysdate                                     --Expected Receipt Date
    63  );
    64  END;
    65   BEGIN
    66  FOR crec IN rcv_interface_cur loop
    67  INSERT INTO rcv_transactions_interface
    68  (
    69               HEADER_INTERFACE_ID,
    70               GROUP_ID,
    71               INTERFACE_TRANSACTION_ID,
    72               TRANSACTION_TYPE,
    73               TRANSACTION_DATE,
    74               PROCESSING_STATUS_CODE,
    75               PROCESSING_MODE_CODE,
    76               TRANSACTION_STATUS_CODE,
    77               CATEGORY_ID,
    78               QUANTITY,
    79               LAST_UPDATE_DATE,
    80               LAST_UPDATED_BY,
    81               CREATION_DATE,
    82               CREATED_BY,
    83               RECEIPT_SOURCE_CODE,
    84               DESTINATION_TYPE_CODE,
    85               AUTO_TRANSACT_CODE,
    86               SOURCE_DOCUMENT_CODE,
    87               UNIT_OF_MEASURE,
    88               INTERFACE_SOURCE_CODE,
    89               ITEM_ID,
    90               --ITEM_DESCRIPTION,
    91               UOM_CODE,
    92               EMPLOYEE_ID,
    93               SHIPMENT_HEADER_ID,
    94               TO_ORGANIZATION_ID,
    95               SUBINVENTORY,
    96               FROM_ORGANIZATION_ID,
    97               FROM_SUBINVENTORY,
    98               EXPECTED_RECEIPT_DATE,
    99               SHIPPED_DATE,
    100               VALIDATION_FLAG
    101  )
    102  VALUES
    103       (v_e,                                          --Header Interface ID
    104       v_f,                                          --Group ID
    105       v_g,                                           --Interface_transaction_id
    106       'RECEIVE',                                       --Transaction Type
    107       sysdate,                                      --Transaction Date
    108       'PENDING',                                    --Processing Status Code
    109       'BATCH',                                      --Processing Mode Code
    110       'PENDING',                                    --Transaction Status Code
    111       120,                                          --Category ID
    112       2,                                           --Quantity
    113       sysdate,                                     --last update date
    114       1053,                                        --last updated by
    115       sysdate,                                      --creation date
    116       1053,                                           --created by
    117       'INVENTORY',                                  --Receipt source Code
    118       'INVENTORY',                                  --Destination Type Code
    119       'DELIVER' ,                                    --AUTO Transact Code
    120       'INVENTORY',                                  --Source Document Code
    121        'Each',                                     --Unit Of Measure
    122        'RCV',                                       --Interface Source Code
    123        2492,                                        --Item ID
    124        --'ABBY KITCHEN CURTAIN SET BEIGE/BURGUNDY',   --Item Description
    125        'EA',                                       --UOM COde
    126        1053,                                       --User
    127       v_c,                                         --Shipment Header ID
    128        v_d,                                        --SHipment Line ID
    129        82,                                           --To Organization ID
    130        'Brooklyn',                                     --Sub Inventory ID
    131        81,                                            --From Organization
    132        'Vessel',                                      --From Subinventory
    133        sysdate,                                       --Expected Receipt Date
    134        sysdate,                                      --Shipped Date
    135        'Y'                                           --Validation Flag
    136      );
    137  --END IF;
    138  END LOOP;
    139  END;
    140*     END xxc_lc_rcv_interface_prc;
    SQL> /
    Warning: Procedure created with compilation errors.
    SQL> sho err
    Errors for PROCEDURE XXC_LC_RCV_INTERFACE_PRC:
    LINE/COL ERROR
    14/2     PLS-00103: Encountered the symbol "SELECT" when expecting one of
             the following:
             begin function pragma procedure subtype type <an identifier>
             <a double-quoted delimited-identifier> current cursor delete
             exists prior
             The symbol "begin" was substituted for "SELECT" to continue.
    141/0    PLS-00103: Encountered the symbol "end-of-file" when expecting
             one of the following:
             ( begin case declare end exception exit for goto if loop mod
             null pragma raise return select update while with
             <an identifier> <a double-quoted delimited-identifier>
             <a bind variable> << continue close current delete fetch lock
             insert open rollback savepoint set sql execute commit forall
             merge pipe purge

    hi,
    I have corrected your code
    CREATE OR REPLACE PROCEDURE xxc_lc_rcv_interface_prc
    IS
       v_a   NUMBER;
       v_b   NUMBER;
       v_c   NUMBER;
       v_d   NUMBER;
       v_e   NUMBER;
       v_f   NUMBER;
       v_g   NUMBER;
       CURSOR rcv_interface_cur
       IS
          SELECT shipment_header_id
            INTO v_c
            FROM rcv_shipment_headers
           WHERE shipment_num = 'NOV';
    BEGIN
       SELECT shipment_line_id
         INTO v_d
         FROM rcv_shipment_lines
        WHERE shipment_header_id = v_c;
       SELECT rcv_headers_interface_s.NEXTVAL
         INTO v_a
         FROM DUAL;
       SELECT rcv_interface_group_s.NEXTVAL
         INTO v_b
         FROM DUAL;
       SELECT rcv_headers_interface_s.CURRVAL
         INTO v_e
         FROM DUAL;
       SELECT rcv_interface_groups_s.CURRVAL
         INTO v_f
         FROM DUAL;
       SELECT rcv_transactions_interface_s.NEXTVAL
         INTO v_g
         FROM DUAL;
       BEGIN
          INSERT INTO rcv_headers_interface
                      (header_interface_id, GROUP_ID, processing_status_code,
                       receipt_source_code, transaction_type,
                       auto_transact_code, last_update_date, last_update_login,
                       last_updated_by, creation_date, created_by,
                       validation_flag, comments, shipment_num, from_organization_id, ship_to_organization_id, expected_receipt_date
                      --RECEIPT_HEADER_ID
               VALUES (v_a,                                  --Header Interface ID
                           v_b,                                         --Group ID
                               'PENDING',                 --Processing Status Code
                       'INVENTORY',                          --Receipt source Code
                                   'RECEIVE',                   --Transaction Type
                       'DELIVER',                              --AUT Transact Code
                                 SYSDATE,                       --last update date
                                         --,                                         --last updated by
                                         --,                                        --Last Update Login
                                         SYSDATE,                  --creation date
    --    ,                                         --created by
                       'Y',                                      --Validation Flag
                           'Receiving Through Interface',               --Comments
                                                         'NOV',  --Shipment Number
    --    ,                                           --From Org
    --    ,                                           --To org
                       SYSDATE                             --Expected Receipt Date
       END;
       BEGIN
          FOR crec IN rcv_interface_cur
          LOOP
             INSERT INTO rcv_transactions_interface
                         (header_interface_id, GROUP_ID,
                          interface_transaction_id, transaction_type,
                          transaction_date, processing_status_code,
                          processing_mode_code, transaction_status_code,
                          category_id, quantity, last_update_date,
                          last_updated_by, creation_date, created_by,
                          receipt_source_code, destination_type_code,
                          auto_transact_code, source_document_code,
                          unit_of_measure, interface_source_code, item_id,
                          --ITEM_DESCRIPTION,
                          uom_code, employee_id, shipment_header_id, to_organization_id, subinventory, from_organization_id, from_subinventory, expected_receipt_date, shipped_date, validation_flag
                  VALUES (v_e,                               --Header Interface ID
                              v_f,                                      --Group ID
                          v_g,                          --Interface_transaction_id
                              'RECEIVE',                        --Transaction Type
                          SYSDATE,                              --Transaction Date
                                  'PENDING',              --Processing Status Code
                          'BATCH',                          --Processing Mode Code
                                  'PENDING',             --Transaction Status Code
    --       ,                                          --Category ID
    --       ,                                           --Quantity
                          SYSDATE,                              --last update date
    --       ,                                        --last updated by
                                  SYSDATE,                         --creation date
    --       ,                                           --created by
                          'INVENTORY',                       --Receipt source Code
                          'INVENTORY',                     --Destination Type Code
                                      'DELIVER',              --AUTO Transact Code
                                                'INVENTORY',
                                                            --Source Document Code
                          'Each',                                --Unit Of Measure
                                 'RCV',                    --Interface Source Code
    --        ,                                        --Item ID
            --'ABBY KITCHEN CURTAIN SET BEIGE/BURGUNDY',   --Item Description
                          'EA',                                         --UOM COde
    --        ,                                       --User
                               v_c,                           --Shipment Header ID
                          v_d,                                  --SHipment Line ID
    --        ,                                           --To Organization ID
                          'Brooklyn',                           --Sub Inventory ID
    --        ,                                            --From Organization
                          'Vessel',                            --From Subinventory
                          SYSDATE,                         --Expected Receipt Date
                                  SYSDATE,                          --Shipped Date
                                          'Y'                    --Validation Flag
          --END IF;
          END LOOP;
       END;
    END xxc_lc_rcv_interface_prc;
    there are many syntax errors i have corrected .
    Note : code is not compiled or tested .Thanks,
    P Prakash
    Edited by: prakash on Nov 21, 2011 4:00 AM

  • Cursor Declaration

    I am trying to declare a cursor in a stored procedure using the following sql:
         CURSOR conversionCursor is select customer_number, company_id , buyer_id
         from hpsiuser.conversion_master natural join
         (select distinct mfg_code, customer_number
                                                 from hpsiuser.vendor_info, invoice_h
                                                 where vendor_id = vendorID);
    I get the following errors:
    Line # = 6 Column # = 29 Error Text = PL/SQL: SQL Statement ignored
    Line # = 6 Column # = 9 Error Text = PLS-00341: declaration of cursor 'CONVERSIONCURSOR' is incomplete or malformed
    Line # = 7 Column # = 43 Error Text = PL/SQL: ORA-06552: PL/SQL: Compilation unit analysis terminated ORA-06553: PLS-320: the declaration of the type of this expression is incomplete or malformed
    My assumption is that it is having a problem with the join yet it works as a stand alone select statement.
    Any insight would be appreciated.
    Jon King

    CURSOR Expressions
    A CURSOR expression returns a nested cursor. This form of expression is equivalent to the PL/SQL REF CURSOR and can be passed as a REF CURSOR argument to a function.
    cursor_expression::=
    Text description of cursor_expression
    A nested cursor is implicitly opened when the cursor expression is evaluated. For example, if the cursor expression appears in a SELECT list, a nested cursor will be opened for each row fetched by the query. The nested cursor is closed only when:
    The nested cursor is explicitly closed by the user
    The parent cursor is reexecuted
    The parent cursor is closed
    The parent cursor is cancelled
    An error arises during fetch on one of its parent cursors (it is closed as part of the clean-up)
    Restrictions on CURSOR Expressions
    If the enclosing statement is not a SELECT statement, nested cursors can appear only as REF CURSOR arguments of a procedure.
    If the enclosing statement is a SELECT statement, nested cursors can also appear in the outermost SELECT list of the query specification, or in the outermost SELECT list of another nested cursor.
    Nested cursors cannot appear in views.
    You cannot perform BIND and EXECUTE operations on nested cursors.
    http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96540/expressions6a.htm#1035109
    Joel P�rez

  • BUG?: unexpected token in connection pane for cursor declaration

    If I declare a cursor with an order clause in the declaration part of a procedure in a package I will get the unexpected token. The code compiles without errors.
    SQL Developer 15.57.
    Windows XP SP2
    Oracle 10g
    example:
    declare procedure test( param in integer ) as
    cursor cur( nVal in integer ) is
    select * from tab where col1 = nVal
    order by col2;
    begin
    NULL;
    end test;
    If I comment out the order by line and proper end the line before all is OK in connection pane.

    There are a few issues logged for these unexpected tokens. We will be reviewing this section for 1.1.
    Regards
    Sue Harper

  • ESQL/C: Difficulties with DECLARE CURSOR  and nested FROM CLAUSE

    Hello @All,
    i am trying to migrate an old esql-c-Application to Oracle 11g (on 64-Bit-AIX 7.1 - Platform)
    PreCompiling is OK, but during runtime the following DECLARE - Statement returns ORA-01001: invalid cursor :
    EXEC SQL
    DECLARE cur_xyz CURSOR FOR
    SELECT vPE, mPE, mZW, COUNT (*)
    FROM ( SELECT v.K_PE AS vPE, m.K_PE AS mPE, m.ZW AS mZW, v.VKG
    FROM ( SELECT K_NR, K_PE, u3.VKG, POS
    FROM u3, r
    WHERE u3.K_NR = '999999'
    AND     u3.LANG = 'F'
    AND SUBSTR (PRTCTRL, 5, 1) > '0'
    AND u3.VKG = r.VKG ( + )
    ) v, m
    WHERE
    v.K_NR = m.K_NR ( + )
    AND v.K_PE = m.K_PE ( + )
    AND POS is Null
    ) X
    WHERE not EXISTS (SELECT VKG FROM NP WHERE X.VKG = NP.VKG )
    GROUP BY vPE, mPE, mZW
    ORDER BY vPE
    When I run this statement without "EXEC SQL DECLARE cur_xyz CURSOR FOR" in SQL-Developer, there is no problem.
    What is my fault? I hope, that I don't have to redesign this.
    Thx in advance for anyonce help.

    Hey Billy,
    I work in a C/C++-Environment under AIX. I allready build a library with with more than x.000 Functions with ESQL-Statements.
    Most of them are running.
    If I need a CURSOR, I allways use constructs like this:
    EXEC SQL DECLARE CursorName [SCROLL]CURSOR FOR
    SELECT ...
    if (SQLC == 0) {
    EXEC SQL OPEN CursorName;
    while (SQLC == 0) {
    EXEC SQL FETCH ... CursorName INTO :<Structure or Fieldlist>;
    EXEC SQL CLOSE CursorName;
    At the Moment, I don't work with a cursor-variable in the DECLARE-Section.
    In the case i discribed above, it is the first, where the ORA-01001 occurs.
    Is it necessary to work with SQL_CURSOR - Variable in all or in special cases?
    Thx 4 answers.

  • How to declare cursors dynamically

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

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

Maybe you are looking for

  • How do I know if my iPod case will protect my iPod touch 4 g

    I have a protective case and one I'm questioning and I want to know if the one I'm questioning will protect my iPod. How do I know if it will protect it from falls

  • How to change language bar that windows supports using google IME

    Brief description about Google IME : Google Transliteration IME is an input method editor which allows users to enter text in one of the supported languages using a roman keyboard. Users can type a word the way it sounds using Latin characters and Go

  • Java.io.UTFDataFormatException: Invalid byte 1 of 1-byte UTF-8 sequence.

    Hi, I see the below error when I try to import bunch of email templates. com.waveset.util.WavesetException: ==> java.io.UTFDataFormatException: Invalid byte 1 of 1-byte UTF-8 sequence. Can any one explain me why is this happenining? Thanks, Siddiqui

  • Reset GL to foreign currency

    Hi SAP FICO Experts, We have gone live on one of our client, while uploading legacy data our client had given us the local currency value for the GL which were in foreign currency, so we made those GL to local currency and uploaded the value. Now the

  • Item description length

    Hi, our one client is from motor industry. their item desc. is upto 85 character they are not interested to maintain it in long text or basic text data. since they want to view description in all transactions not only in reports and printing document