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

Similar Messages

  • Error while opening cursor

    Hi ,
    In a procedure ,
    I have a cursor query which gets me the sum of a sum(to_number(field_value1) grouped on a list of other fields.The datatype of that field_value1 is varchar2
    It has been running fine till now.But somehow , some non-numeric characters have been entered into this field.
    As a result the query is failing.
    I want the value of the other field for which the query is failing.
    What happens is the open is successful(The sqlcode after open cursor is 0 , but actually the cursor%found is false)
    The program continues into the fetch loop and jumps to the exception handler where I get the correct error which is 1722 Invalid number.
    I am not in a position to get exactly for which row the fetch is failing.
    Also , we are dealing with a huge volume of data , approximately (10000000) after grouping , so can't think of ungrouping the query and checking the value explicitly.
    Please Help.
    Thanks.

    Hi,
    I have created a stored function for handling this issue.
    Just check this code i have written the value in a file.
    =======================================
    CREATE OR REPLACE FUNCTION Chk_Number(S VARCHAR2) RETURN NUMBER is
    J VARCHAR2(10);
    FP UTL_FILE.FILE_TYPE;
    BEGIN
    J:=to_NUMBER(S);
    RETURN J;
    exception
    WHEN VALUE_ERROR THEN
         FP := UTL_FILE.FOPEN('/tmp','tmpt0','w');
         UTL_FILE.PUT_LINE(FP,S);
         UTL_FILE.FCLOSE(FP);
         RETURN 0;
    END;
    =======================
    DECLARE
    CURSOR C1 is select sum(Chk_Number(no)) NO
    from abc;
    BEGIN
    FOR R1 in C1
    LOOP
    DBMS_OUTPUT.PUT_LINE(R1.NO);
    END LOOP;
    END;
    This is one of the way.
    vinod

  • In ECC 6 , I AM  GETTING ERROR WHILE DECLARING DATA TYPE OF BAPI

    HI,
    IN ECC 6 , i AM  GETTING ERROR" NO READ ACESS RETURN"
    EVENTHOUGH   I DECLARED  DATA TYPE   FOR EXAMPLE
    DATA: RETURN TYPE BAPIRET2.AND USING IN RFC.
    HOW TO CORRECT THE ERROR.
    pLZ HELP ME.
    REGARDS,
    RANI

    Hi Rani,
    Could you please post the piece of coding where the error comes from? Maybe we can help you then.
    Regards,
    John.

  • Error while declaring the internal table

    Hi all,
    I am trying to declare as following and I am getting the error
    data: begin of test,
          w_text(1000),
          end of test.
    data: i_test type standard table of test.

    Hello
    types: begin of test,
    w_text(1000),
    end of test.
    data: i_test type standard table of test.

  • Error while declaring RT_PERSON using pnpce ldb

    when am declaring
    data : RT_PERSON like line of PC2RT_PERSON.
    am getting an error msg that
    "FIELD 'PC2RT_PERSON' is unknown .it is neither in the specified tables, nor in the DATA statement".
    whatz the error .what should i do.
    points will be rewarded.
    thanks in advance.

    declare as :
    data : RT_PERSON like PC2RT_PERSON.

  • Error while executing Procedure - ORA-06511: PL/SQL: cursor already open

    I have successfully compiled the following procedure but when I execute it, following error occurs, please adv.
    Thanks and Regards,
    Luqman
    create or replace
    procedure TESTKIBOR
    (contno in varchar)
    AS
    BEGIN
    DECLARE cursor c1 is
    SELECT * FROM KIBOR_SCHEDULE
    WHERE CN=contno;
    begin
    OPEN C1;
    FOR line IN c1 LOOP
    update kibor_schedule
    set lincome=line.Lincome,
    expo=line.eXPO,
    pport=line.pPORT
    where cn=line.cn
    and rno=line.rno;
    END LOOP;
    COMMIT;
    close c1;
    END;
    END TESTKIBOR;
    ERROR at line 1:
    ORA-06511: PL/SQL: cursor already open
    ORA-06512: at "MKTG.TESTKIBOR", line 6
    ORA-06512: at "MKTG.TESTKIBOR", line 10
    ORA-06512: at line 1

    Hi,
    CREATE OR REPLACE PROCEDURE Testkibor
         (contno  IN VARCHAR)
    AS
    BEGIN
      DECLARE
        CURSOR c1 IS
          SELECT *
          FROM   kibor_schedule
          WHERE  cn = contno;
      BEGIN
    --//    OPEN c1; --no need to open if using for loop
        FOR line IN c1 LOOP
          UPDATE kibor_schedule
          SET    lincome = line.lincome,
                 expo = line.expo,
                 pport = line.pport
          WHERE  cn = line.cn
                 AND rno = line.rno;
        END LOOP;
        COMMIT;
    --//     CLOSE c1; -- no need for loop  does it for you
      END;
    END testkibor;SS

  • SQL*Loader-925: Error while parsing a cursor (via ocisq)

    Receiving the following error message when trying to use SQLLoader (on NT) >>>
    SQL*Loader-925: Error while parsing a cursor
    (via ocisq)
    ORA-00942: table or view does not exist
    Trying to use the application for the first time, logon using userid for which sqlplus operates, and the table does exist under the user schema, as owner.
    ctl and dat file are correct. Log file gives me no further detail of the errors.
    Are there any configuration settings or something required for this app?
    Thanks

    Thanks Warren. I was concentrating more on the first line of the error.
    You are right. The issue was of insufficient privileges. The table did not have all the necessary grants provided.

  • Invalid cursor state error while executing the prepared statement

    hai friends,
    following code showing the invalid cursor state error while executing the second prepared statement.
    pls anyone help me
    String query = "select * from order_particulars where order_no=" + orderno + " order by sno";             psmt1 = conEntry.prepareStatement(query, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);             rs1 = psmt1.executeQuery();             rs1.last();             intRowCount = rs1.getRow();             particularsdata = new Object[intRowCount][6];             rs1.beforeFirst();             if (intRowCount >= 1) {                 for (int i = 0; rs1.next(); i++) {                     particularsdata[0] = i + 1;
    particularsdata[i][1] = rs1.getString(3);
    particularsdata[i][2] = Double.parseDouble(rs1.getString(4));
    rs1.close();
    psmt1.close();
    query = "SELECT sum(delqty) FROM billdetails,billparticulars WHERE order_no= " + orderno + " and " +
    "billdetails.bill_no = billparticulars.bill_no GROUP BY particulars ORDER BY sno";
    psmt1 = conEntry.prepareStatement(query, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
    rs1 = psmt1.executeQuery(); //error showing while executing this line

    Also .. Why using arrays instead of collections? Shifting the cursor all the way forth and back to get the count is fairly terrible.
    With regard to the problem: either there's a nasty bug in the JDBC driver used, or you actually aren't running the compiled class version of the posted code.

  • Getting errors while comipling the cursor

    Hi,
    Currently I am trying to take the output of the query in a cursor.
    Once receving the data. I want to perform the delete operation on the fetched rows.
    For this I have built Package containing :-
    1. Procedure Spefification :-
    CREATE OR REPALCE
    PACKAGE MAIN_1 AS
    PROCEDURE MAIN_2
    CHILD_ID VARCHAR2,
    DMN VARCHAR2,
    PARENT_ID OUT VARCHAR2,
    PARENT_ID OUT VARCHAR2,
    C_CR OUT VARCHAR2
    END MAIN_1;
    2. Procedure Body
    create or replace
    PACKAGE BODY MAIN_1 AS
    PROCEDURE MAIN_2
    CHILD_ID VARCHAR2,
    DMN VARCHAR2,
    PARENT_ID OUT VARCHAR2,
    C_CR OUT VARCHAR2
    IS
    CURSOR C1 IS
    SELECT H.CHILD_ID,CONNECT_BY_ISLEAF AS NO_CHILDREN_EXIST
    FROM MY_EX_TBL H
    START WITH PRNT_ID = CHILD_ID
    CONNECT BY PRNT_ID = CHILD_ID ;
    C_ROW C1%ROWTYPE;
    BEGIN
    IF (
    CHILD_ID IS NULL
    OR
    DMN IS NULL
    THEN
    DBMS_OUTPUT.PUT_LINE ('NO DATA');
    ELSE
    --few lines of code
    END IF;
    OPEN C1;
    LOOP
    FETCH C1 INTO C_ROW;
    EXIT WHEN C1%NOTFOUND;
    FOR C_ROW IN C1
    LOOP
    DELETE FROM MY_EX_TBL WHERE CURRENT OF C1;
    END LOOP;
    END LOOP;
    CLOSE C1;
    END MAIN_2;
    END MAIN_1;
    But when i try to compile it i am getting the following errors:-
    1. Error(): PL/SQL: SQL Statement ignored
    2. Error(): PLS-00404: cursor 'C1' must be declared with FOR UPDATE to use with CURRENT OF
    3. Error(): PL/SQL: ORA-00904: : invalid identifier
    I tried to debug it but not able to... :(
    can anyone would plz. mind to provide a helping hand in this ....plz.
    Thnks

    Woah... take a step back.
    You've essentially put every SQL I posted into your code. I was just demonstrating things in stages to try and help you understand. The conclusion I came to was that you just needed the DELETE statement, based on the information you had given.
    Let's look back at what you said:
    I have the following data in my Main table
    CHILD_ID     PARENT_ID
    ASD0l12eds   ASD0l12edn
    ASD0l58ppo   ASD0l16uui
    ASD0l17jji   ASD0l19nnk
    ASD0l12edm   ASD0l12edn
    ASD0l19dds   ASD0l12edn
    ASD0l16tdp   ASD0l16uui
    ASD0l10kko   ASD0l16uui Expected Result :-
    CHILD_ID     PARENT_ID
    ASD0l12eds   ASD0l12edn
    ASD0l12edm   ASD0l12edn
    ASD0l19dds   ASD0l12edn
    ASD0l17jji   ASD0l19nnk
    ASD0l58ppo   ASD0l16uui
    ASD0l16tdp   ASD0l16uui
    ASD0l10kko   ASD0l16uui Here, your expected result is the same as your main table, just with the rows showing in a different order, so there's no useful information in that.
    You then say...
    WHAT I GOT (ACTUAL RESULT) :-
    CHILD_ID     PARENT_ID     NO_CHILDREN_EXIST
    ASD0l17jji   ASD0l19nnk    0
    ASD0l17jji   ASD0l19nnk    0
    ASD0l17jji   ASD0l19nnk    0
    ASD0l17jji   ASD0l19nnk    0
    ASD0l17jji   ASD0l19nnk    0
    ASD0l17jji   ASD0l19nnk    0
    ASD0l17jji   ASD0l19nnk    0NOTE:-
    NO_CHILDREN_EXIST = 0 WHEN CHILD Record is present
    NO_CHILDREN_EXIST = 1 WHEN CHILD Record is not presentThe fact you're getting an output like that is because your writing a hierarchical query against data which has no hierarchy, and at the same time, your "CONNECT BY" clause is not appropriate as it does not reference any PRIOR row. A Hierarchical query has different levels to it (like folders/directories in your MS Windows file system). In the data you've shown you just have a list of records where non of the child_id's exist as parent_id's so there is only the one level, and hence why all your records show no children.
    You then say:
    EXPECTED RESULT :-
    CHILD_ID     PARENT_ID     NO_CHILDREN_EXIST
    ASD0l17jji   ASD0l19nnk    0
    which doesn't make any sense. Why do you expect that 1 record as the result? Is that the record you expect after you've deleted other records, or is that the record you expect to delete? What is the logic that determines that record over other records?
    As you can see (hopefully), you haven't actually explained what the problem is so that we can help properly. The code you've tried, and the fact you've got data with "child_id" and "parent_id" seems to indicate that you want some sort of hierarchical query, but the data you've provided doesn't actually have any hierarchy to it, so none of the records (based on these facts) have any children.
    So, if I create a few other records in the data, just to demonstrate to you what a hierarchical query looks like...
    SQL> col tree_view format a30
    SQL>
    SQL> with t as (select 'ASD0l12eds' as child_id, 'ASD0l12edn' as parent_id from dual union all
      2             select 'ASD0l58ppo','ASD0l16uui' from dual union all
      3             select 'ASD0l17jji','ASD0l19nnk' from dual union all
      4             select 'ASD0l12edm','ASD0l12edn' from dual union all
      5             select 'ASD0l19dds','ASD0l12edn' from dual union all
      6             select 'ASD0l16tdp','ASD0l16uui' from dual union all
      7             select 'ASD0l10kko','ASD0l16uui' from dual union all
      8             select 'ASD0l18ggg','ASD0l58ppo' from dual union all -- new record
      9             select 'ASD0l11aaa','ASD0l18ggg' from dual union all -- new record
    10             select 'ASD0l13abc','ASD0l19dds' from dual           -- new record
    11            )
    12  --
    13  -- end of example data
    14  --
    15  select level as lvl
    16        ,parent_id
    17        ,child_id
    18        ,connect_by_isleaf as leaf_record
    19        ,lpad(' ',(level-1)*2,' ')||child_id as tree_view
    20  from   t
    21  connect by parent_id = prior child_id
    22  start with parent_id not in (select child_id from t)
    23  /
           LVL PARENT_ID  CHILD_ID   LEAF_RECORD TREE_VIEW
             1 ASD0l12edn ASD0l12edm           1 ASD0l12edm
             1 ASD0l12edn ASD0l12eds           1 ASD0l12eds
             1 ASD0l12edn ASD0l19dds           0 ASD0l19dds
             2 ASD0l19dds ASD0l13abc           1   ASD0l13abc
             1 ASD0l16uui ASD0l10kko           1 ASD0l10kko
             1 ASD0l16uui ASD0l16tdp           1 ASD0l16tdp
             1 ASD0l16uui ASD0l58ppo           0 ASD0l58ppo
             2 ASD0l58ppo ASD0l18ggg           0   ASD0l18ggg
             3 ASD0l18ggg ASD0l11aaa           1     ASD0l11aaa
             1 ASD0l19nnk ASD0l17jji           1 ASD0l17jji
    10 rows selected.Here you can see that the new records I've added have parent_id's that are also child_id's of other records, so that means that they are child records of those other records.
    The "level" can be used to see which records are top level parents of the hierarchical tree, and the connect_by_isleaf can be used to see which records have no children underneath them.
    So, either your data is not truly hierarchical or, it is but you have not provided a good example of data for us to work with.
    You also need to explain which 'child' records you want to delete. Are you just talking of removing leaf nodes from the tree? or are you talking of removing any children records (those which are not level 1 records)?

  • Error while creating new projects using api

    Hello,
    I am having error while creating projects using standard api, PA_PROJECT_PUB.CREATE_PROJECTS. The error I am having is as follow.
    Source template ID is invalid.
    ===
    My code is as follow:
    SET SERVEROUTPUT ON SIZE 1000000
    SET VERIFY OFF
    define no=&amg_number
    DECLARE
    -- Variables used to initialize the session
    l_user_id NUMBER;
    l_responsibility_id NUMBER;
    cursor get_key_members is
    select person_id, project_role_type, rownum
    from pa_project_players
    where project_id = 1;
    -- Counter variables
    a NUMBER := 0;
    m NUMBER := 0;
    -- Variables needed for API standard parameters
    l_commit VARCHAR2(1) := 'F';
    l_init_msg_list VARCHAR2(1) := 'T';
    l_api_version_number NUMBER :=1.0;
    l_return_status VARCHAR2(1);
    l_msg_count NUMBER;
    l_msg_data VARCHAR2(2000);
    -- Variables used specifically in error message retrieval
    l_encoded VARCHAR2(1) := 'F';
    l_data VARCHAR2(2000);
    l_msg_index NUMBER;
    l_msg_index_out NUMBER;
    -- Variables needed for Oracle Project specific parameters
    -- Input variables
    l_pm_product_code VARCHAR2(30);
    l_project_in pa_project_pub.project_in_rec_type;
    l_key_members pa_project_pub.project_role_tbl_type;
    l_class_categories pa_project_pub.class_category_tbl_type;
    l_tasks_in pa_project_pub.task_in_tbl_type;
    -- Record variables for loading table variables above
    l_key_member_rec pa_project_pub.project_role_rec_type;
    l_class_category_rec pa_project_pub.class_category_rec_type;
    l_task_rec pa_project_pub.task_in_rec_type;
    -- Output variables
    l_workflow_started VARCHAR2(100);
    l_project_out pa_project_pub.project_out_rec_type;
    l_tasks_out pa_project_pub.task_out_tbl_type;
    -- Exception to call messag handlers if API returns an error.
    API_ERROR EXCEPTION;
    BEGIN
    -- Initialize the session with my user id and Projects, Vision Serves (USA0
    -- responsibility:
    select user_id into l_user_id
    from fnd_user
    where user_name = 'SSHAH';
    select responsibility_id into l_responsibility_id
    from fnd_responsibility_tl
    where responsibility_name = 'Projects Implementation Superuser';
    pa_interface_utils_pub.set_global_info(
    p_api_version_number => l_api_version_number,
    p_responsibility_id => l_responsibility_id,
    p_user_id => l_user_id,
    p_msg_count => l_msg_count,
    p_msg_data => l_msg_data,
    p_return_status => l_return_status);
    if l_return_status != 'S' then
    raise API_ERROR;
    end if;
    -- Provide values for input variables
    -- L_PM_PRODUCT_CODE: These are stored in pa_lookups and can be defined
    -- by the user. In this case we select a pre-defined one.
    select lookup_code into l_pm_product_code
    from pa_lookups
    where lookup_type = 'PM_PRODUCT_CODE'
    and meaning = 'Conversion';
    -- L_PROJECT_IN: We have to provide values for all required elements
    -- of this record (see p 5-13, 5-14 for the definition of the record).
    -- Customers will normally select this information from some external
    -- source
    l_project_in.pm_project_reference := 'AGL-AMG Project &no';
    l_project_in.project_name := 'AGL-AMG Project &no';
    l_project_in.created_from_project_id := 1;
    l_project_in.carrying_out_organization_id := 2864; /*Cons. West*/
    l_project_in.project_status_code := 'UNAPPROVED';
    l_project_in.start_date := '01-JAN-11';
    l_project_in.completion_date := '31-DEC-11';
    l_project_in.description := 'Trying Hard';
    l_project_in.project_relationship_code := 'Primary';
    -- L_KEY_MEMBERS: To load the key member table we load individual
    -- key member records and assign them to the key member table. In
    -- the example below I am selecting all of the key member setup
    -- from an existing project with 4 key members ('EE-Proj-01'):
    for km in get_key_members loop
    -- Get the next record and load into key members record:
    l_key_member_rec.person_id := km.person_id;
    l_key_member_rec.project_role_type := km.project_role_type;
    -- Assign this record to the table (array)
    l_key_members(km.rownum) := l_key_member_rec;
    end loop;
    -- L_CLASS_CATEGORIES: commented out below should fix the error we get
    -- because the template does not have an assigment for the mandatory class
    -- 'BAS Test'
    l_class_category_rec.class_category := 'Product';
    l_class_category_rec.class_code := 'Non-classified';
    -- Assign the record to the table (array)
    l_class_categories(1) := l_class_category_rec;
    -- L_TASKS_IN: We will load in a single task and a subtask providing only
    -- the basic fields (see pp. 5-16,5-17,5-18 for the definition of
    -- the task record)
    l_task_rec.pm_task_reference := '1';
    l_task_rec.pa_task_number := '1';
    l_task_rec.task_name := 'Construction';
    l_task_rec.pm_parent_task_reference := '' ;
    l_task_rec.task_description := 'Plant function';
    -- Assign the top task to the table.
    l_taskS_in(1) := l_task_rec;
    -- Assign values for the sub task
    l_task_rec.pm_task_reference := '1.1';
    l_task_rec.pa_task_number := '1.1';
    l_task_rec.task_name := 'Brick laying';
    l_task_rec.pm_parent_task_reference := '1' ;
    l_task_rec.task_description := 'Plant building';
    -- Assign the subtask to the task table.
    l_tasks_in(2) := l_task_rec;
    -- All inputs are assigned, so call the API:
    pa_project_pub.create_project
    (p_api_version_number => l_api_version_number,
    p_commit => l_commit,
    p_init_msg_list => l_init_msg_list,
    p_msg_count => l_msg_count,
    p_msg_data => l_msg_data,
    p_return_status => l_return_status,
    p_workflow_started => l_workflow_started,
    p_pm_product_code => l_pm_product_code,
    p_project_in => l_project_in,
    p_project_out => l_project_out,
    p_key_members => l_key_members,
    p_class_categories => l_class_categories,
    p_tasks_in => l_tasks_in,
    p_tasks_out => l_tasks_out);
    -- Check the return status, if it is not success, then raise message handling
    -- exception.
    IF l_return_status != 'S' THEN
    dbms_output.put_line('Msg_count: '||to_char(l_msg_count));
    dbms_output.put_line('Error: ret status: '||l_return_status);
    RAISE API_ERROR;
    END IF;
    -- perform manual commit since p_commit was set to False.
    COMMIT;
    --HANDLE EXCEPTIONS
    EXCEPTION
    WHEN API_ERROR THEN
    FOR i IN 1..l_msg_count LOOP
    pa_interface_utils_pub.get_messages(
    p_msg_count => l_msg_count,
    p_encoded => l_encoded,
    p_msg_index => i,
    p_msg_data => l_msg_data,
    p_data => l_data,
    p_msg_index_out => l_msg_index_out);
    dbms_output.put_line('ERROR: '||to_char(l_msg_index_out)||': '||l_data);
    END LOOP;
    rollback;
    WHEN OTHERS THEN
    dbms_output.put_line('Error: '||sqlerrm);
    FOR i IN 1..l_msg_count LOOP
    pa_interface_utils_pub.get_messages(
    p_msg_count => l_msg_count,
    p_encoded => l_encoded,
    p_msg_index => i,
    p_msg_data => l_msg_data,
    p_data => l_data,
    p_msg_index_out => l_msg_index_out);
    dbms_output.put_line('ERROR: '||to_char(l_msg_index_out)||': '||l_data);
    END LOOP;
    rollback;
    END;
    ===
    Msg_count: 1
    Error: ret status: E
    ERROR: 1: Project: 'AGL-AMG Project 1123'
    Source template ID is invalid.
    PL/SQL procedure successfully completed.

    I was using a custom Application, which had a id other then 275 (which belongs to Oracle projects)

  • Error while running due to tabletype

    Hi All,
    I am getting error while runnning procedure but it compiled successfully.
    ORA-00932: inconsistent datatypes: expected - got -
    I have created a Object Type and by referring that tobject type, i have created a table type. then i have created a variable of that table type.
    But when i am using that vairiable in Cursor's fetch statement, it throws the above error at runtime.
    The code is something like this:
    create or replace procedure PROC_SP_MASTER_UPLOAD(p_Return Out Number) is
    -- Creating Table Type
    -- ot_sp_master is Object Type
    Type tt_ot_sp_master is Table of ot_sp_master;
    --creating Cursor
    TYPE c_ref_cursor IS REF CURSOR;
    --Declaring Variables
    old_cursor_sp c_ref_cursor;
    v_tt_ot_sp_master tt_ot_sp_master := tt_ot_sp_master();
    v_sql_existing_instrument varchar(1000):= ' SELECT T_INSTRUMENT_ID,T_INSTRUMENT_ANALYSIS_GROUP,T_ASSET_LIABILITY_ID,T_REGION_ID,T_INSTRUMENT_STATUS,
    T_INSTRUMENT_WEB,T_APPROVED_INVESTMENT FROM T_MASTER_SP WHERE T_INSTRUMENT_ID IS NOT NULL ';
    Begin
    Open old_cursor_sp for v_sql_existing_instrument;
    Loop
    Fetch old_cursor_sp Bulk collect into v_tt_ot_sp_master LIMIT 5000; // throws error at this line
    ForAll i in v_tt_ot_sp_master.first..v_tt_ot_sp_master.last
    Update MST_INSTRUMENT mst set
    mst.region_id =TREAT(v_tt_ot_sp_master(i) as ot_sp_master).region_id,
    mst.issuer_country =TREAT(v_tt_ot_sp_master(i) as ot_sp_master).issuer_country,
    mst.asset_liab_id =TREAT(v_tt_ot_sp_master(i) as ot_sp_master).asset_liability_id,
    mst.instrument_web =TREAT(v_tt_ot_sp_master(i) as ot_sp_master).instrument_web,
    mst.instrument_analysis_group =TREAT(v_tt_ot_sp_master(i) as ot_sp_master).instrument_analysis_group,
    mst.approved_inv =TREAT(v_tt_ot_sp_master(i) as ot_sp_master).approved_investment
    Where mst.instrument_id=TREAT(v_tt_ot_sp_master(i) as ot_sp_master).instrumentid;
    Exit When old_cursor_sp%NOTFOUND;
    End Loop;
    End PROC_SP_MASTER_UPLOAD;
    I don't know why it is throwing this error, may be due to object type......
    Thanks

    may be try this, make sure the mappining in update set column is correct
    CREATE OR REPLACE PROCEDURE PROC_SP_MASTER_UPLOAD (
      p_Return          OUT NUMBER)
    IS
      CURSOR cur
      IS
        SELECT T_INSTRUMENT_ID,
               T_INSTRUMENT_ANALYSIS_GROUP,
               T_ASSET_LIABILITY_ID,
               T_REGION_ID,
               T_INSTRUMENT_STATUS,
               T_INSTRUMENT_WEB,
               T_APPROVED_INVESTMENT
          FROM T_MASTER_SP
         WHERE T_INSTRUMENT_ID IS NOT NULL;
      TYPE tt_ot_sp_master IS TABLE OF cur%ROWTYPE;
      v_tt_ot_sp_master tt_ot_sp_master;
    BEGIN
      OPEN cur;
      LOOP
        FETCH cur
        BULK COLLECT INTO v_tt_ot_sp_master LIMIT 5000;                                                                   
        FORALL i IN v_tt_ot_sp_master.FIRST .. v_tt_ot_sp_master.LAST
          UPDATE MST_INSTRUMENT mst
             SET mst.region_id = v_tt_ot_sp_master (i).T_REGION_ID,
                 mst.issuer_country = v_tt_ot_sp_master (i).T_issuer_country,
                 mst.asset_liab_id = v_tt_ot_sp_master (i).T_ASSET_LIABILITY_ID,
                 mst.instrument_web = v_tt_ot_sp_master (i).T_INSTRUMENT_WEB,
                 mst.instrument_analysis_group = v_tt_ot_sp_master (i).T_INSTRUMENT_ANALYSIS_GROUP,
                 mst.approved_inv = v_tt_ot_sp_master (i).T_APPROVED_INVESTMENT
           WHERE mst.instrument_id = v_tt_ot_sp_master (i).T_INSTRUMENT_ID;
        EXIT WHEN old_cursor_sp%NOTFOUND;
      END LOOP;
    commit;
    END PROC_SP_MASTER_UPLOAD;added commit which was missing in original post
    Message was edited by:
    devmiral

  • Getting Incorrect data type error while trying to do a CAST in table

    Getting an error while trying to compile the following piece of code
    CREATE OR REPLACE PACKAGE BODY A_pkg AS
    FUNCTION A(O_error_message IN OUT varchar2)
    RETURN BOOLEAN IS
    --Declaring the local variables and CURSORs used in the program unit
    L_attrib_tbl CFA_SQL.TYP_attrib_tbl;
    cursor c1 is
    select list_first1.number_11
    from TABLE (CAST (L_attrib_tbl AS "CFA_SQL.TYP_attrib_tbl")) list_first1;
    BEGIN
    L_group_id = '22'
    IF L_merch_type_value = 'G' OR L_merch_type_value = 'I' THEN
    CFA_SQL.QUERY_ATTRIB(L_attrib_tbl,
    L_group_id) ;
    END IF;
    open C1;
    Fetch C1 into L_number;
    close C1;
    return true;
    END A;
    END;
    Also pasting the Spec for CFA_SQL which contains TYP_attrib_tbl
    TYPE TYP_attrib_rec IS RECORD
    group_id CFA_ATTRIB_GROUP.GROUP_ID%TYPE,
    varchar2_1 VARCHAR2,
    number_11 number(10,0));
    TYPE TYP_attrib_tbl is TABLE of TYP_attrib_rec INDEX BY BINARY_INTEGER;
    The error is coming in the line
    cursor c1 is
    select list_first1.number_11
    from TABLE (CAST (L_attrib_tbl AS "CFA_SQL.TYP_attrib_tbl")) list_first1;
    with the error as Invalid data type pointing to CFA_SQL.TYP_attrib_tbl as invalid, but I have initialized L_attrib_tbl as of that datatype only. Ahy help would be greatly appreciated.
    Regards,
    Joydeep

    Hi Kelly,
    There is no data that is entered in that period.The data will be entered for that period next month.
    POV is also not set to that period,but still the problem persists.
    Thanks

  • Error while populating a list

    Hi People,
    I use oracle forms 10g.While i was trying to populate item in poplist i was thrown with following error as,
    Error,
    wrong number or types of arguments in call to 'ADD_LIST_ELEMENT'
    and I have written the following code in WHEN-NEW-FORM-INSTANCE,
    declare
         cursor c is select ename from emp;
         ena emp.ename%type;
    begin
              for ena in c loop
    add_list_element('block3.list5',1,ena,ena);
              end loop;
              end;Can u pls help me to find out what could be wrong.thanks in advance.
    With Regards
    Vids

    This one?
    declare
         cursor c is select ename from emp;
       begin
        for ena in c loop
          add_list_element('block3.list5',1,ena.ename);
        end loop;
      end;
    or
    declare
         cursor c is select ename, rownum rn from emp;
       begin
        for ena in c loop
          add_list_element('block3.list5',ena.rn, ena.ename);
        end loop;
      end;

  • Error while populating Xref database

    Hi All,
    I am populating Xref database through ODI, but while executing it i am getting this error--
    com.sunopsis.sql.SnpsMissingParametersException: Missing parameter
    The error is generated at this step..Insert Flow into I$ table(sql code)
    /* Use of a PL-SQL bloc to perform the Insert (management of LONGS and LOBS etc.) */
    declare cursor myCursor is
    select      
         oramds:/apps/AIAMetaData/xref/JOBCODE_ID.xref     XREF_TABLE_NAME,
         #LOADJOBDETAILSINSTAGINGTABLE.GetSourceColumnName     XREF_COLUMN_NAME,
         SYS.GUID()     ROW_NUMBER,
         C1_VALUE     VALUE,
         'N'     IS_DELETED,
         CURRENT_TIMESTAMP     LAST_MODIFIED ,
         'I'     IND_UPDATE
    from      AIA11G_XREF.C$_0XREF_DATA
    where     (1=1)
    begin
         /* Loop over the Cursor and execute the insert statement */
         for aRecord in myCursor loop
              insert into     AIA11G_XREF.I$_XREF_DATA
                   XREF_TABLE_NAME,
                   XREF_COLUMN_NAME,
                   ROW_NUMBER,
                   VALUE,
                   IS_DELETED,
                   LAST_MODIFIED,
                   IND_UPDATE
              values      (
                   aRecord.XREF_TABLE_NAME,
                   aRecord.XREF_COLUMN_NAME,
                   aRecord.ROW_NUMBER,
                   aRecord.VALUE,
                   aRecord.IS_DELETED,
                   aRecord.LAST_MODIFIED,
                   aRecord.IND_UPDATE
         end loop;
    end;
    In the step Create Flow table I$--the sql generated is:-
    create table AIA11G_XREF.I$_XREF_DATA
         XREF_TABLE_NAME     VARCHAR2(2000) NULL,
         XREF_COLUMN_NAME     VARCHAR2(2000) NULL,
         ROW_NUMBER     VARCHAR2(48) NULL,
         VALUE     VARCHAR2(2000) NULL,
         IS_DELETED     VARCHAR2(1) NULL,
         LAST_MODIFIED     TIMESTAMP NULL,
         IND_UPDATE      char(1)
    NOLOGGING
    My source and target both are of oracle technology and i have imported LKM SQL to Oracle and IKM Oracle Incremental Update(pl/sql) and CKM
    and my odi version is 10.1.3.5
    Please solve this problem
    Regards,
    Sourav
    Edited by: user13263578 on Feb 22, 2011 9:18 PM
    Edited by: user13263578 on Feb 22, 2011 9:19 PM
    Edited by: user13263578 on Feb 23, 2011 4:03 AM

    Hi,
    You can copy the SQL code generated by ODI ( for the step giving this error) and then try to execute it via any SQL client like toad/ sql developer etc.
    This will help you to find the wrong data .
    Also is LAST_MODIFIED and LAST_ACCESSED have datatype as VARCHAR2 ? From the name it seems it is ment to have DATE .
    Thanks,
    Sutirtha

  • Error while updating assignment of Contingent resource

    Hi,
    I am getting the below error while updating Assignment of contingent resource using the Standard API.
    ORA-20001: HR_7949_ASG_DIF_SYSTEM_TYPE: N, SYSTYPE, ACTIVE_CWKCode for updating the record is -
    Declare
    Cursor c_emp_mig
    Is
    Select person_id, supervisor_person_id, code_comb_id, sob,  assignment_id, assignment_number From  customContingentTable;
      x_person_id number;
    x_validate BOOLEAN := FALSE;
    x_supervisor_id number;
    x_default_code_comb_id number;
    x_set_of_books_id number;
    x_assignment_id number;
    x_assignment_number varchar2(20);
    x_manager_flag char(1):='N';
    x_comment_id number;
    x_concatenated_segments varchar2(80);
    x_no_managers_warning boolean ;
    x_cagr_concatenated_segments VARCHAR2(80);
    x_soft_coding_keyflex_id NUMBER; --- IN OUT
    x_other_manager_warning boolean;
    x_object_version_number NUMBER;
    x_cagr_grade_def_id  NUMBER;
    x_effective_date DATE :='01-OCT-2011'; --cut off date from which the assignment will be effective
    x_effective_start_date DATE  :='01-OCT-2011';--cut off date from which the assignment will be effective
    x_effective_end_date   DATE;
    x_hourly_salaried_warning boolean;
    x_org_now_no_manager_warning boolean;
    x_error_code varchar2(240);
    x_error_desc varchar2(2000);
    Begin
       Open c_emp_mig;
       Loop
       Fetch c_emp_mig Into x_person_id, x_supervisor_id, x_default_code_comb_id, x_set_of_books_id, x_assignment_id, x_assignment_number;
       Exit when c_emp_mig%NOTFOUND;
        x_object_version_number:=1;
        hr_assignment_api.update_cwk_asg(
         p_validate => x_validate
         ,p_effective_date => x_effective_date
         ,p_datetrack_update_mode => 'UPDATE'
         ,p_assignment_id => x_assignment_id
         ,p_assignment_status_type_id => 1
         ,p_assignment_number =>x_assignment_number
         ,p_object_version_number => x_object_version_number
         ,p_default_code_comb_id => x_default_code_comb_id
         ,p_set_of_books_id => x_set_of_books_id
         ,p_supervisor_id=>x_supervisor_id
         ,p_manager_flag=>x_manager_flag
         ,p_concatenated_segments => x_concatenated_segments
         ,p_soft_coding_keyflex_id => x_soft_coding_keyflex_id
         ,p_comment_id => x_comment_id
         ,p_effective_start_date => x_effective_start_date
         ,p_effective_end_date => x_effective_end_date
         ,p_no_managers_warning => x_no_managers_warning
         ,p_other_manager_warning => x_other_manager_warning
         ,p_hourly_salaried_warning=>x_hourly_salaried_warning 
         ,p_org_now_no_manager_warning=>x_org_now_no_manager_warning
          End Loop;
       Exception When Others Then
             x_error_code:=SQLCODE;
             x_error_desc:=SQLERRM;
            insert into emp_mig_error(error_code, error_desc) values(x_error_code, x_error_desc);  
         Close c_emp_mig;
      End;   Am I missing something here? I searched in metalink, there is no mention of this error. Can anyone help?
    Regds,
    ARS

    The relevant parameter to identify an individual will be p_assignment_id.
    You will need a query to obtain the relevant assignment_id from the given CWK number on the person row
    Edited to add : whilst you are about it, you'll need to obtain the assignment object_version_number as well - that will be needed for the p_object_version_number parameter
    Edited by: clive_t on 05-Apr-2012 16:10

Maybe you are looking for

  • Where can I get a cable to connect my 2nd generation iPod to a USB port on a Windows PC?

    My wife wants to give her old iPod to her sister but we don't have a cable that will connect to a PC's USB port.  Are there adapters or something similar available that will enable our old 2nd generation iPod to communicate with a PC via a USB connec

  • Photo viewer issue in N8

    when i opened the photo viewer to view photos, it takes more time to load (the loading symbol is rotating for more than minute).This was not the actual opening time before.If i try to exit the viewer, i couldn't,the display is switched off for a whil

  • Macbook pro using all bandwidth

    I have a MacBook Pro for use at my work. Our internet connection is not the best but recently i have been told that my PC is using all the bandwidth, even when i have very few programs running. The company telephone is run on the internet and when I'

  • Condition Types in different Tables

    I have couple of condition types in my pricing procedure and they are all flowing in sale order and billing. For various purpose, I want to take some reports based on these condition types and hence, I considered tables A303,  A305, A515 etc., It has

  • PowerPivot/Excel Services from SQL 2008 R2

    I am currently setting up a SharePoint 2013 instance. At my company we have an existing SQL Server 2008 R2 (SP1) installation with SSAS, which users are currently accessing with Excel 2010 & 2013 PowerPivot. Is it possible to access the Analysis Serv