The cursor declaration error

Hi all, when I'm trying to declare a cursor in a procedure, I get errors. Please correct me where I'm 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

Not before the CURSOR, but before the SELECT INTO after the cursor...

  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
 10   CURSOR rcv_interface_cur
 11   IS
 12   SELECT shipment_header_id INTO v_c
 13   FROM RCV_SHIPMENT_HEADERS
 14   WHERE SHIPMENT_NUM = 'NOV1124';

  

 15   SELECT shipment_line_id INTO v_d
 16   FROM RCV_SHIPMENT_LINES
 17   WHERE SHIPMENT_HEADER_ID = v_c;
 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
 ...

Tags: Database

Similar Questions

  • with the use of the clause in the cursor

    is it possible to use with the clause in the cursor declaration.

    See the simple example below.

    It gives an error.



    declare

    cursor t is

    (with Salvation as

    (select * from pepole)


    Select distinct hi.id of salvation where id = 55);


    Start


    null;


    end;

    Remove the outdoor set of parentheses.

    declare
    
    cursor t is
    with hi as
    (select * from emp )
    select distinct sal from hi;
    begin
    null;
    end;
    
  • Cursor of return of (nested) function - PLS-00201: identifier of the CURSOR must be declared

    Hello

    I have a function in which I use nested functions (because I don't want to create objects explicit / external, it is a requirement that I don't have any effect on / I don't want to change).

    In my external function, I use cursor by declaring them in IS-section and then open using the loop for instruction.

    In my inner function / nested, I also want to use a cursor.

    There I also said one like I did in an external function within the section IS of the nested function.

    SQL Developer complains about syntax error (';: wait ").

    When you try to compile the whole process I get the following error:

    "Error (97,14): PLS-00201: identifier 'CURSOR' must be declared '.

    It's my external function starts as:

    CREATE OR REPLACE FUNCTION FN_GENERATE_QUERY_PMT (instance_id_in IN NUMBER, language_in IN VARCHAR2)
    RETURN CLOB
    IS
         CURSOR c_outer IS
          SELECT * FROM BLA;
    

    When it comes to my internal function with the section IS of the external function and stands (inner functions should be at the end of the Section IS to stand behind the statements of variable and cursor, otherwise there will be an error):

    FUNCTION nfn_get_value (num_in IN NUMBER)
          RETURN SYS_REFCURSOR
        IS
          SYS_REFCURSOR c_inner IS
          SELECT *
          FROM BLUB;
        BEGIN
          RETURN c_where_in;
        END;
    

    After that there will be another nested function, then the BEGIN section will appear.

    When looking for 'function returns cursor' I can only find solutions where the cursor is declared in section IS (sometimes its an AS-section o_O * worried *) but wihtoug select, just declare type.

    The cursor focus is added in the Begin block to the way open for instruction. But I don't want to open it yet. I want to open the cursor using the loop statement. I am able to reopen? used can it be two sliders while one will not be closed properly?

    How to fix to return a cursor that I can use in my external function.

    Advice would be appreciated.

    Thanks in advance.

    Maybe I got the soultion
    First of all, I found this thread:

    http://asktom.Oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:5241391331097

    said the following:

    2) a ref cursor is just a cursor.  a ref cursor is just a cursor.  a ref cursor is just a cursor.... (keep saying it over and over
    

    But fortuneately I also found this post:
    http://asktom.Oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:14188501024541

    where thankfully someone shared her knowledge with others:

    In view of this block of code - you may see more "prominent" unlike - any

    How many times you run this block - cursor C will always be select * twice.  The ref

    cursor is not guaranteed.

    Another difference is that a ref cursor can be returned to a client.  a plsql 'cursor cursor.

    cannot be returned to a client.

    Another difference is a cursor can be global - a ref cursor cannot (you cannot set

    them outside a procedure / function)

    Another difference is a ref cursor can be passed to the subroutine - a subroutine

    cursor cannot be.

    This explains why the samples seem always fair with open (Ref) cursor within the section to START.

    I expeceted this (as I wrote in the first post) and ask if the course of opening will be sent back twice or just redirect. I suppose it it reassigns who were just a little in performance.

    But I can't yet find this good explanation of this type anywhere within the documentation and of course I didn't read it all. Shame on me, but I'm always engaged by internet download.

    I would be grateful if someone could say my last statement and leave a comment on double-distribution of the refcursors has reopened.

    Thanks in advance.

  • What is the significance of the CURSOR WITH HOLD clause in a cursor declaration?

    What is the significance of the CURSOR WITH HOLD clause in a cursor declaration?

    A cursor that has been declared with the clause WITH HOLD, after the word CURSOR remains open after a COMMIT or a ROLLBACK. The following example shows how to use the following clause:

         EXEC SQL          DECLARE C1 CURSOR WITH HOLD          FOR SELECT ENAME FROM EMP          WHERE EMPNO BETWEEN 7600 AND 7700      END-EXEC.
    

    The cursor must not be declared for the UPDATE. The WITH HOLD clause is used in DB2 to override the default, which is to close all cursors on validation. Pro * COBOL provides this clause in order to facilitate the migration of applications to DB2 to Oracle. When MODE = ANSI, use Oracle DB2 default, but all host variables must be declared in a declare Section.

    Reference:

    Oracle documentation!
    http://docs.Oracle.com/CD/B10501_01/AppDev.920/a96109/pco03dbc.htm

  • Remove the statement that uses a subselect in the declaration of the cursor

    Hi all

    How to write write a delete statement that uses a subselect with the declaration of the cursor?

    CURSOR excluded_dates IS          
           SELECT TO_TIMESTAMP(report_parameter_value, in_date_format_mask)
          INTO my_current_date_time
          FROM report_parameters
         WHERE report_parameters.report_parameter_id    = in_report_parameter_id
           AND report_parameters.report_parameter_group = 'DATE_TIME'
           AND report_parameters.report_parameter_name  = 'EXCLUDED_DATE';
     OPEN excluded_dates;
      
      LOOP
        
        FETCH excluded_dates INTO my_excluded_date;
        
        EXIT WHEN excluded_dates%NOTFOUND;
        
        DELETE FROM edr_rpt_tmp_inclusion_table
        WHERE TO_CHAR(date_time, 'mm/dd/yyyy') = TO_CHAR(my_excluded_date, 'mm/dd/yyyy');
        
      END LOOP;
    
      CLOSE excluded_dates;
    Thank you

    Hello

    You can turn your cursor into a subquery IN

    DELETE FROM edr_rpt_tmp_inclusion_table
    WHERE   TRUNC (date_time) IN
    (
           SELECT TRUNC (TO_TIMESTAMP(report_parameter_value, in_date_format_mask))
    --      INTO my_current_date_time   -- Remove this line
          FROM report_parameters
         WHERE report_parameters.report_parameter_id    = in_report_parameter_id
           AND report_parameters.report_parameter_group = 'DATE_TIME'
           AND report_parameters.report_parameter_name  = 'EXCLUDED_DATE'
    );
    

    I used the TRUNK instead of TO_CHAR, but it works with TO_CHAR.

    Published by: Frank Kulash, June 8, 2009 11:28
    Remove the "my_current_date_time" line, after Sean and Sanjay (below).

  • Declare the cursor within the begin/end block

    Hi all
    Can we declare a cursor inside a begin/end block. If we can, please let me know how. I want to declare a cursor where it will return value based on the settings of the user. User will enter in as username(for example), we have to recover the ID, the user name and we must move to cursor. To do this, we wrote a query to fetch id in a variable in the other block of start/end and we pass this variable in the cursor. Is this possible.



    Thank you and best regards,
    Mahesh

    In general, yes you can, you simply nest another block of execution inside of your...

    begin
      declare
        cursor x is select dummy from dual;
      begin
        ...
      end;
    end;
    /
    
  • Gets the cursor not valid error on line 6?

    create or replace procedure cust_pack (p_dept_id in number, p_emp_id number) is
    number of v_credit_limit: = 2000;
    cursor cur_cust (p_dept_id in number, p_emp_id number) is
    Select first_name, last_name, salary from employee where department_id = p_dept_id and employee_id = p_emp_id;
    Start
    for cust_record in cur_cust (50,188)
    loop
    dbms_output.put_line (' name ='| cust_record.last_name |', Sal ='| cust_record.salary);
    close cur_cust;
    end loop;
    end;
    /
    Please rectify the problem...

    Please rectify the problem...

    Remove this

    close cur_cust;
    

    You do not close the cursor yourself in a cursor for loop and especially not while you use it.

    http://docs.Oracle.com/CD/B19306_01/AppDev.102/b14261/loop_statement.htm#LNPLS01328

    Concerning
    Peter

  • Using bulk collect into with assistance from the limit to avoid the TEMP tablespace error run out?

    Hi all

    I want to know if using bulk collect into limit will help to avoid the TEMP tablespace error run out.

    We use Oracle 11 g R1.

    I am assigned to a task of creating journal facilitated for all tables in a query of the APEX.

    I create procedures to execute some sql statements to create a DEC (Create table select), and then fires on these tables.

    We have about three tables with more than 26 million records.

    It seems very well running until we reached a table with more than 15 million record, we got an error says that Miss tablespace TEMP.

    I googled on this topic and retrieve the tips:

    Use NO LOG

    Parallel use

    BULK COLLECT INTO limited

    However, the questions for those above usually short-term memory rather than running out of TEMPORARY tablespace.

    I'm just a junior developer and does not have dealed with table more than 10 million documents at a time like this before.

    The database support is outsourced. If we try to keep it as minimal contact with the DBA as possible. My Manager asked me to find a solution without asking the administrator to extend the TEMP tablespace.

    I wrote a few BULK COLLECT INTO to insert about 300,000 like once on the development environment. It seems.

    But the code works only against a 000 4000 table of records. I am trying to add more data into the Test table, but yet again, we lack the tablespace on DEV (this time, it's a step a TEMP data)

    I'll give it a go against the table of 26 million records on the Production of this weekend. I just want to know if it is worth trying.

    Thanks for reading this.

    Ann

    I really need check that you did not have the sizes of huge line (like several K by rank), they are not too bad at all, which is good!

    A good rule of thumb to maximize the amount of limit clause, is to see how much memory you can afford to consume in the PGA (to avoid the number of calls to the extraction and forall section and therefore the context switches) and adjust the limit to be as close to that amount as possible.

    Use the routines below to check at what threshold value would be better suited for your system because it depends on your memory allocation and CPU consumption.  Flexibility, based on your limits of PGA, as lines of length vary, but this method will get a good order of magnitude.

    CREATE OR REPLACE PROCEDURE show_pga_memory (context_in IN VARCHAR2 DEFAULT NULL)

    IS

    l_memory NUMBER;

    BEGIN

    SELECT st. VALUE

    IN l_memory

    SYS.v_$ session se, SYS.v_$ sesstat st, SYS.v_$ statname nm

    WHERE se.audsid = USERENV ('SESSIONID')

    AND st.statistic # nm.statistic = #.

    AND themselves. SID = st. SID

    AND nm.NAME = 'pga session in memory. "

    Dbms_output.put_line (CASE

    WHEN context_in IS NULL

    THEN NULL

    ELSE context_in | ' - '

    END

    || 'Used in the session PGA memory ='

    || To_char (l_memory)

    );

    END show_pga_memory;

    DECLARE

    PROCEDURE fetch_all_rows (limit_in IN PLS_INTEGER)

    IS

    CURSOR source_cur

    IS

    SELECT *.

    FROM YOUR_TABLE;

    TYPE source_aat IS TABLE OF source_cur % ROWTYPE

    INDEX BY PLS_INTEGER;

    l_source source_aat;

    l_start PLS_INTEGER;

    l_end PLS_INTEGER;

    BEGIN

    DBMS_SESSION.free_unused_user_memory;

    show_pga_memory (limit_in |) "- BEFORE"); "."

    l_start: = DBMS_UTILITY.get_cpu_time;

    OPEN source_cur.

    LOOP

    EXTRACTION source_cur

    LOOSE COLLECTION l_source LIMITED limit_in;

    WHEN l_source EXIT. COUNT = 0;

    END LOOP;

    CLOSE Source_cur;

    l_end: = DBMS_UTILITY.get_cpu_time;

    Dbms_output.put_line (' elapsed time CPU for limit of ')

    || limit_in

    || ' = '

    || To_char (l_end - l_start)

    );

    show_pga_memory (limit_in |) "- AFTER");

    END fetch_all_rows;

    BEGIN

    fetch_all_rows (20000);

    fetch_all_rows (40000);

    fetch_all_rows (60000);

    fetch_all_rows (80000);

    fetch_all_rows (100000);

    fetch_all_rows (150000);

    fetch_all_rows (250000);

    -etc.

    END;

  • Binding of varchar2 twice to the cursor on DB_LINK

    I have an oracle 12 c database. After the migration of 11g there is a problem with our package that migrates data from a DB2 database. Here is a part of the packaging that is causing trouble and I turned so it can be run on a worksheet.

    declare

    Directory of l_cur5;

    whole l_row;

    Start

    l_cur5: = DBMS_HS_PASSTHROUGH. OPEN_CURSOR@DB_LINK;

    DBMS_HS_PASSTHROUGH. PARSE @DB_LINK(l_cur5

    , ' select 1

    of dctp.plastic plc

    where plc.code = rpad (?, 60, "")');

    DBMS_HS_PASSTHROUGH. Bind_variable@DCMS_DCTP_CHD (l_cur5, 1, '2010000003');

    l_row: = DBMS_HS_PASSTHROUGH. FETCH_ROW@DCMS_DCTP_CHD (l_cur5, true);

    DBMS_OUTPUT. Put_line (l_row);

    DBMS_HS_PASSTHROUGH. Bind_variable@DCMS_DCTP_CHD (l_cur5, 1, '2010000003');

    l_row: = DBMS_HS_PASSTHROUGH. FETCH_ROW@DCMS_DCTP_CHD (l_cur5, true);            -It crashes here if two variables are varchar2

    DBMS_OUTPUT. Put_line (l_row);

    DBMS_HS_PASSTHROUGH. CLOSE_CURSOR@DCMS_DCTP_CHD (l_cur5);

    exception

    while others then

    DBMS_OUTPUT. PUT_LINE (SQLCODE);

    DBMS_OUTPUT. PUT_LINE (SQLERRM);

    end;

    /

    Replacing the value '2010000003' with 2010000003 works ok and the procedure ends without problem.


    Having two variables of type varchar2, gives a > ORA-28513: internal error in remote agen heterogeneous < error.


    On Oracle 11 g the procedure completed successfully even with two varchar2 variables.


    If I close the cursor between the two bonds, that the procedure ends with success.


    Does your company have a support contract? If so - talk to your administrator (the person in your company who manages the support), get the CSI number and create an account on MOS.

    If you do not support, there's really no channel for reports (or indeed get a fix), as all the patches would require a support contract.

  • How to assign values to the current element where the cursor is?

    Hi all

    I have a block of "tabular" data, B_Emp (from the Employee table) and the other non-database & non tabular block consisting of a text_items B_Test.

    'Emp_id' is one of the column in the Employee table and I want to attribute all the values of the Emp_id in all text_items of the B_Test in order, when you press a particular key.

    Here's what I wrote in the trigger

    Declare

    i the number;

    number of l_last_record;

    next varchar2 (40); -to hold the values of cursor system of the next item in the block of B_Test

    next_r varchar2 (40); -to hold the values of cursor system of the next record in the block of B_Emp

    Begin

    go_block ('B_Emp');

    Set_Block_Property ('B_EMPLOYEES_ALL', DEFAULT_WHERE, "Emp_id is not null");

    execute_query (no_validate);

    last_record;

    l_last_record: =: system.cursor_record;

    premier_enregistrement;

    next_r: =: SYSTEM. CURSOR_ITEM;

    go_block ('B_Test');

    Next: =: SYSTEM. CURSOR_ITEM;

    because me in 1.l_last_record

    Loop

    go_item (Next);

    : next: =: B_Emp.Emp_id;-here is the problem

    next_item;

    Next: =: SYSTEM. CURSOR_ITEM;

    go_item (next_r);

    next_record;

    next_r: =: SYSTEM. CURSOR_ITEM;

    WHEN THE OUTPUT: SYSTEM. LAST_RECORD = "TRUE";

    End loop;

    End;

    Now, this gives me the expected bad Bind Variable error as there is no block of data with the name "next".

    However, I checked the value of 'next' and 'next_r' (message (' value = ' | next)) and I'm getting the expected values.

    So if somewhere, I am able to put my value in the current item the cursor (because at the beginning of the loop, my cursor system is exactly to the text element where I need to insert the value) so I did not have to use this " : next: =: B_Emp.Emp_id;"

    OR

    If somewhere, I am able to return the items in my B_test block dynamically so I can simply use

    Loop

    ": B_test." dynamic reference for the element ": = : B_Emp.Emp_id;

    next_record;

    WHEN THE OUTPUT: SYSTEM. LAST_RECORD = "TRUE";



    Please help me out of this!

    Guy! I found a solution for the same thing.

    We can use integrated a 'copy' to set the values of the element where currently is cursor system.

    The syntax will be

    Copy ((new_value): System.Cursor_Item);

    -where new_value is the variable that contains the data to be assigned.

    In addition, we can assign the values from the system cursor to any variable.

    The syntax will be '

    new_value: =: System.Cursor_Value;

    Thanks a lot guys for your help and concern

    See you soon!

  • Cannot create the plsql procedure, fails at the cursor

    He was a working procedure that would take ID and then copy the data from the source to the destination parameter parameter. Now I would like to have the NAME as a parameter, I changed the code to accommodate the new settings. But I'm not able to create the procedure. I get error 3-CURSOR (in bold red). I would really appreciate if someone can take a look and let me know what the problem is.

    Thanks in advance

    3 errors

    1 PLS-00103: encountered the symbol "CUR_V_HSP_COLUMN_DETAIL" during the expected in the following way:

    := . ( @ % ;

    The symbol ': = ' was replaced by 'CUR_V_HSP_COLUMN_DETAIL' continue.

    2 PLS-00103: encountered the symbol "NUMBER" when expecting one of the following conditions:

    (

    The symbol "(" was substituted for "NUMBER" to continue.

    3 PLS-00103: encountered the symbol "NUMBER" when expecting one of the following conditions:

    (

    CREATE or REPLACE procedure EPM_PLAN_PLANSAMP. Copy_Details_test1 - Arguments

    ( IN VARCHAR2, HSP_object in_From_Version_Name.) Object_name - Version of

    in_From_Scenario_Name IN VARCHAR2, HSP_object. Object_name - scenarios of

    in_From_Year_Name IN VARCHAR2, HSP_object. Object_name - year from

    in_To_Version_Name IN VARCHAR2, HSP_object. Object_name - Version to

    in_To_Scenario_name IN VARCHAR2, HSP_object. Object_name - scenarios

    in_To_Year_Name IN VARCHAR2 - HSP_object. Object_name - year to

    )

    IS

    number of v_From_Object_Id; -Version of

    number of s_From_Object_Id; -Scenarios of

    number of y_From_Object_Id; -The year of

    number of v_To_Object_Id; -Version to

    number of s_To_Object_Id; -Scenarios to

    number of y_To_Object_Id; -The year to

    BEGIN

    Select object_id in v_From_Object_Id

    of hsp_object

    where type_objet = 35

    and object_name = in_from_version_name;

    Select object_id in s_From_Object_Id

    of hsp_object

    where type_objet = 31

    and object_name = in_from_scenario_name;

    Select object_id in y_From_Object_Id

    of hsp_object

    where type_objet = 38

    and object_name = in_from_year_name;

    Select object_id in v_To_Object_Id

    of hsp_object

    where type_objet = 35

    and object_name = in_to_version_name;

    Select object_id in s_To_Object_Id

    of hsp_object

    where type_objet = 31

    and object_name = in_to_scenario_name;

    Select object_id in y_To_Object_Id

    of hsp_object

    where type_objet = 38

    and object_name = in_to_year_name;

    -Select Details of support for the current Version

    CURSOR Cur_V_HSP_COLUMN_DETAIL (cV_From_Object_Id in NUMBER, cS_From_Object_Id number) IS

    Select DETAIL_ID in the EPM_PLAN_PLANSAMP. HSP_COLUMN_DETAIL where DIM5 = cV_From_Object_Id AND DIM1 = cS_From_Object_Id;

    li_DETAIL_ID NUMBER;

    Li_Next_DETAIL_ID NUMBER;

    FETCH_STATUS NUMBER: = 0;

    v_step_name varchar2 (200);

    v_rec_cnt number: = 0;

    number of v_cnt;

    v_err varchar2 (2000);

    -----------------------------------------Begin Copy Version ---------------------------

    BEGIN

    -Removed next version if already exists

    v_step_name: = 'delete the HSP_COLUMN_DETAIL_ITEM ";

    Remove from HSP_COLUMN_DETAIL_ITEM

    Where DETAIL_ID in (Select DETAIL_ID from HSP_COLUMN_DETAIL

    Where = v_To_Object_Id AND DIM1-DIM5 = s_To_Object_Id);

    v_cnt: = number of lines sql %;

    insert into t_copy_supporting_dtls_log values (v_step_name, v_cnt, 1, sysdate, 'success');

    v_step_name: = 'delete the HSP_COLUMN_DETAIL ";

    Remove from HSP_COLUMN_DETAIL

    where = v_To_Object_Id AND DIM1-DIM5 = s_To_Object_Id;

    v_cnt: = number of lines sql %;

    insert into t_copy_supporting_dtls_log values (v_step_name, v_cnt, 1, sysdate, 'success');

    Open Cur_V_HSP_COLUMN_DETAIL (v_From_Object_Id, s_From_Object_Id);

    v_step_name: = "Insert";

    LOOP

    Look FOR Cur_V_HSP_COLUMN_DETAIL IN li_DETAIL_ID;

    WHEN the OUTPUT Cur_V_HSP_COLUMN_DETAIL % NOTFOUND;

    -Find the next detail_id

    Select Max (DETAIL_ID) + 1 IN HSP_COLUMN_DETAIL Li_Next_DETAIL_ID;

    -Insert in the Table HSP_COLUMN_DETAIL

    Insert into HSP_COLUMN_DETAIL (DETAIL_ID, PLAN_TYPE, DIM1, DIM2, DIM3, DIM4, DIM5, 6,

    DIM7, DIM8, DIM9, DIM10, DIM11, DIM12, DIM13, DIM14, DIM15,

    DIM16, DIM17, DIM18, DIM19, DIM20)

    Select Li_Next_DETAIL_ID, PLAN_TYPE, S_To_Object_Id, DIM2, DIM3, DIM4, V_To_Object_Id, 6.

    DIM7, DIM8, DIM9, DIM10, DIM11, DIM12, DIM13, DIM14, DIM15,

    DIM16, DIM18, DIM19, DIM17, DIM20

    Of HSP_COLUMN_DETAIL

    Where DETAIL_ID = li_DETAIL_ID;

    v_rec_cnt: = v_rec_cnt + sql rowcount %;

    -Insert in the Table HSP_COLUMN_DETAIL_ITEM

    Insert into HSP_COLUMN_DETAIL_ITEM (DETAIL_ID, VALUE, POSITION, GENERATION, OPERATOR, LABEL)

    Select VALUE, POSITION, GENERATION, OPERATOR, Li_Next_DETAIL_ID, LABEL

    From HSP_COLUMN_DETAIL_ITEM where DETAIL_ID = li_DETAIL_ID;

    v_rec_cnt: = v_rec_cnt + sql rowcount %;

    END LOOP;

    Close Cur_V_HSP_COLUMN_DETAIL;

    insert into t_copy_supporting_dtls_log values (v_step_name, v_rec_cnt, 1, sysdate, 'success');

    commit;

    exception when others then

    Rollback;

    v_err: = substr (sqlerrm, 1, 2000);

    insert into t_copy_supporting_dtls_log values (v_step_name, 0, -1, v_err, sysdate);

    commit;

    END;

    END;

    /

    You DECLARE the cursor before using it.

  • INVALID CURSOR - block anonymous component the cursor in function

    I get an error when you try to call my cursor.
    CREATE OR REPLACE PACKAGE tax_update
    AS
     TYPE gencur IS ref cursor;
     FUNCTION tax_sf
     (
       p_state IN bb_tax.state%type,
       p_thecursor IN OUT gencur
     )
     RETURN NUMBER;
    END;
    / 
    CREATE OR REPLACE PACKAGE BODY tax_update
    AS
     FUNCTION tax_sf
     (
       p_state IN bb_tax.state%type,
       p_thecursor IN OUT gencur
     )
     RETURN NUMBER
      IS
      lv_taxrate NUMBER;
     BEGIN
      OPEN p_thecursor FOR 
       SELECT taxrate 
       FROM bb_tax
       WHERE state = p_state;
      RETURN lv_taxrate;
     END;
    END;
    / 
    DECLARE
      tax_cur tax_update.gencur;
      rec_tax bb_tax%rowtype;
     BEGIN
     LOOP
      FETCH tax_cur INTO rec_tax;
       EXIT WHEN tax_cur%NOTFOUND;
        DBMS_OUTPUT.PUT_LINE(rec_tax.taxrate);
     END LOOP;
    END;
    DECLARE
    *
    ERROR at line 1:
    ORA-01001: invalid cursor
    ORA-06512: at line 6
    Mission is to create a package that will contain the rate of taxation by the State in a packed slider. The package contains a function that can receive a State of 2 character abbreviated as an argument and finds a match in the cursor and return the tax rates for tha tstate. An anonymous block will test the function with the State of North Carolina.
    If anyone can help?

    user13842802 wrote:
    Have tried a few ways to call but always error on TAX_SF.

    SET SERVEROUTPUT ON
    DECLARE
        tax_cur tax_update.gencur;
        rec_tax bb_tax%rowtype;
    BEGIN
        tax_cur := tax_update.tax_sf('NC');
        LOOP
          FETCH tax_cur INTO rec_tax;
          EXIT WHEN tax_cur%NOTFOUND;
          DBMS_OUTPUT.PUT_LINE(rec_tax.taxrate);
        END LOOP;
    END;
    /
    

    SY.

  • Appellant the package with the cursor type and registration type variables

    Hello
    I tried the following package, which is similar to my requriement, the package has been successfully created, when you call it gives me error, the number of false arguments
    CREATE OR REPLACE PACKAGE Pkg_test1
    IS
      ----- Record Variable ----
      TYPE rec_job IS RECORD
       ( job varchar2(50),
         ename varchar2(50),
         sal number
       );
      TYPE typ_job IS TABLE OF rec_job;
      
      -- cursor declaration
      cursor emp_cur is select empno from  emp;
      TYPE emp_ttyp IS TABLE OF emp_cur%ROWTYPE INDEX BY PLS_INTEGER;
      ---- Procedure Declaration ----
    PROCEDURE proc_job ( p_cur IN   emp_ttyp,
                         o_Rat     OUT  typ_job );
     
    END Pkg_test1;
    /
    
    CREATE OR REPLACE PACKAGE BODY Pkg_test1
    IS
     
     PROCEDURE proc_job ( p_cur IN   emp_ttyp, o_Rat     OUT  typ_job )
      IS 
        -- Declare collection variable 
        l_typ_job typ_job; 
     
    BEGIN
       for i  in 1..p_cur.count loop
        select job,ename,sal bulk collect into l_typ_job
          from emp
          where empno=p_cur(i).empno ; 
    o_Rat:= l_typ_job;
    end loop;
    --Output
    for i in 1..o_rat.count loop
     DBMS_OUTPUT.PUT_LINE ( 'Output :'||o_rat(i).job||','||o_rat(i).ename||','||o_rat(i).sal );
      end loop;
    
    EXCEPTION
      WHEN OTHERS THEN 
           DBMS_OUTPUT.put_line('Procedure proc_job  - '|| SQLCODE|| '-'|| SQLERRM);
     END proc_job;
      end pkg_test1;
    /
    The package is created without errors
    But during the call, it gives me errors
    DECLARE 
      P_CUR PKG_TEST1.emp_ttyp;
      O_RAT PKG_TEST1.rec_job;
    BEGIN 
      PKG_TEST1.PROC_JOB ( P_CUR, O_RAT );
      COMMIT; 
    END; 
    Error is:
    PLS-00306: wrong number or types of arguments in call to 'PROC_JOB'
    Can you let me see how to overcome this error...

    Thank you..

    Published by: Smile on 9 may 2012 07:27
    SQL> DECLARE
      2  P_CUR PKG_TEST1.emp_ttyp;
      3  O_RAT PKG_TEST1.typ_job := PKG_TEST1.typ_job(null);
      4  BEGIN
      5  PKG_TEST1.PROC_JOB ( P_CUR, O_RAT );
      6  END;
      7  /
    Procedure proc_job  - -6531-ORA-06531: Reference to uninitialized collection
    
    PL/SQL procedure successfully completed.
    
    SQL> CREATE OR REPLACE PACKAGE BODY Pkg_test1
      2  IS
      3
      4   PROCEDURE proc_job ( p_cur IN   emp_ttyp, o_Rat     OUT  typ_job )
      5    IS
      6      -- Declare collection variable
      7      l_typ_job typ_job := typ_job();
      8
      9  BEGIN
     10     for i  in 1..p_cur.count loop
     11      select job,ename,sal bulk collect into l_typ_job
     12    from emp
     13    where empno=p_cur(i).empno ;
     14  o_Rat:= l_typ_job;
     15  end loop;
     16  --Output
     17  if o_rat is null then return; end if;
     18  for i in 1..o_rat.count loop
     19   DBMS_OUTPUT.PUT_LINE ( 'Output :'||o_rat(i).job||','||o_rat(i).ename||','||o_rat(i).sal );
     20    end loop;
     21  EXCEPTION
     22    WHEN OTHERS THEN
     23     DBMS_OUTPUT.put_line('Procedure proc_job  - '|| SQLCODE|| '-'|| SQLERRM);
     24   END proc_job;
     25    end pkg_test1;
     26  /
    Package body created.
    
    SQL> DECLARE
      2  P_CUR PKG_TEST1.emp_ttyp;
      3  O_RAT PKG_TEST1.typ_job;
      4  BEGIN
      5  PKG_TEST1.PROC_JOB ( P_CUR, O_RAT );
      6  END;
      7  /
    
    PL/SQL procedure successfully completed.
    
    SQL> 
    

    SY.

  • Plu SQL hang up when the cursor is fired.

    Hello
    I'm just a beginner in sql and plsql. I run the cursor query as below in my sql more window:

    Declare
    CURSOR emp_cursor IS SELECT * FROM employees WHERE employee_id = 100;
    employees emp_record % rowtype;
    Begin
    OPEN emp_cursor;
    LOOP
    LOOK INTO emp_record emp_cursor;
    DBMS_OUTPUT. Put_line (emp_record);
    END LOOP;
    NARROW Emp_cursor;
    END;

    While I try to run the plu SQL hang (the cursor (_) flashes to a new line in trying to retrieve the result). Even after 10-15 minutes the result is displayed and I cannot type in any other question, that the system is not ready. In short sql plu hangs up.

    Add the exit condition

    FETCH emp_cursor INTO emp_record;
    exit when emp_cursor%notfound;
    

    also your call to DBMS_OUTPUT. Procedure put_line() is not.
    It takes a VARCHAR2 as an input parameter, when you pass a variable with employees % rowtype.
    For me, it showed the following error:

    DBMS_OUTPUT.PUT_LINE(emp_record);
    *
    ERROR at line 8:
    ORA-06550: line 8, column 1:
    PLS-00306: wrong number or types of arguments in call to 'PUT_LINE'
    

    That should be:

    DBMS_OUTPUT.PUT_LINE(emp_record.employee_id); --Or whatever columns you want to display
    
  • How do I know the cursor for loop host variable contains data or not

    Hi all


    can someone tell me how to know cursor variable host loop for contains data or not.


    example:
    Start
    for curr_rec in (select * from double)
    loop

    dbms_output.put_line(curr_rec%ROWCOUNT);

    end loop;


    end;

    The following oracle error message is coming:

    ORA-06550: line 5, column 27:
    PLS-00324: cursor attribute can only be applied to non slider "CURR_REC."

    Please help me.

    Thank you and best regards,
    Prakash P

    Published by: 833560 on April 19, 2011 21:57

    833560 wrote:
    Hi all

    can someone tell me how to know cursor variable host loop for contains data or not.

    example:
    Start
    for curr_rec in (select * from double)
    loop

    dbms_output.put_line(curr_rec%ROWCOUNT);

    end loop;

    end;

    The following oracle error message is coming:

    ORA-06550: line 5, column 27:
    PLS-00324: cursor attribute can only be applied to non slider "CURR_REC."

    Please help me.

    Thank you best regards &,.
    Prakash P

    Published by: 833560 on April 19, 2011 21:57

    You know, in your code curr_rec is not slider.
    You cannot use curr_rec % rowcount
    If you want to get the number of lines of your loop, then use an additional variable

    Try this please

    declare
     countLoop NUMBER :=0;
    begin
      for curr_rec in( select * from dual)
      loop
        countloop := countloop + 1;
    
      end loop;
      dbms_output.put_line(countloop);
    end;
    

    or

    DECLARE
            CURSOR csr_org IS
                  SELECT empno, ename FROM   emp;
                  num_total_rows NUMBER;
          BEGIN
                  FOR idx IN csr_org LOOP
                      dbms_output.put_line(idx.empno||' '||idx.ename);
                      num_total_rows := csr_org%ROWCOUNT;
                  END LOOP;
                  IF num_total_rows > 0 THEN
                    dbms_output.new_line;
                    dbms_output.put_line('Total Organizations = '||to_char(num_total_rows));
                  END IF;
       END;
     /
    

    Published by: Mahir M. Quluzade, April 20, 2011 10:19

Maybe you are looking for

  • System Restore does not work? Help, please

    Restore failed I tried to restore my system to an earlier time, but I get this message? No changes have been made to your computer. System Restore could not restore your computer about to restore specified. Select a different restore point, and then

  • DDR3 memory

    HP pavilion dv7 notebookPC System ID: 149C Product ID: XE375EA #ABF Serial number: [under the direction of personal information] my original memory is 2 GB, it switch to 1 x 4 GB and I have I have a blue error screen. Can someone help me solve this p

  • R400 - am I the only one? Laughing out loud

    I see a lot here on the old series edition r. but I don't seem to see anyone with the newest of r400. I just bought one and I was wondering what other people who already think about it. Unfortunately, there is not much comment or something on the r40

  • record of events

    Hello I'm new to blackberry environment. I need to keep a log file for all events. I just tried Lod, using a text file. But it took to sign the code of the key. But I think that there are a class of available logging already in blackberry that can be

  • Activate the authorization mode failed.

    Have a user who cannot get to en guest. Here is my trace output: AAA/AUTHENTIC: user = "lduncan" update_user ruser = '(null)' port = "telnet146" rem_addr = '10.128.20.110' authen_type = 1 = ENABLE private service = 152007 10:57:07.360 16 Oct EAST -04