Calling a procedure from within a trigger

Hi,
I have a table (table1) which when a row is inserted into this table I need to populate a number of tables based upon gathering information from multiple tables using three fields passed in from table 1.
I therefore proposed to create a before insert trigger on table1 calling a procedure which passes in the three new values as follows:
CREATE OR REPLACE TRIGGER trigger1
BEFORE INSERT ON table1
FOR EACH ROW
BEGIN
package1.populate_tables(:new.col1, :new.col2, :new.col3) ;
END;
This compiles fine, but when I actually insert data in table1 then I receive the following message and do not know how to get round it:
ORA-04091: table table1 is mutating, trigger/function may not see it.
I am using other fields in table1 to insert values into other tables (confusing I know).
If anyone can help me I would appreciate it, or if you require any more information I would be very happy to provide it.
Thanks in advance.

Hi,
You triggered in fired on table and you procedure in acting is on the same table which rasing the exception.
Go throw this link you will understand
http://asktom.oracle.com/tkyte/Mutate/
- Pavan Kumar N

Similar Messages

  • How to call a procedure from within another procedure?

    What's the syntax to call a procedure from within a procedure.
    I have a procedure z(user_id IN number, ....)
    then
    procedure a (user_id IN number, ....)
    procedure b (user_id IN number, ....)
    procedure c (user_id IN number, ....)
    I want to call procedure a, b, c from inside procedure z.
    How would I do that?

    Same way :
    SCOTT@db102 SQL> create or replace procedure a (p1 in varchar2) is
      2  begin
      3     dbms_output.put_line (p1);
      4* end;
    SCOTT@db102 SQL> /
    Procedure created.
    SCOTT@db102 SQL> create or replace procedure z (par1 in number) is
      2  begin
      3     if par1 != 0 then
      4             a ('This is proc a');
      5     end if;
      6* end;
    SCOTT@db102 SQL> /
    Procedure created.
    SCOTT@db102 SQL> set serveroutput on
    SCOTT@db102 SQL> exec z (1);
    This is proc a
    PL/SQL procedure successfully completed.
    SCOTT@db102 SQL>                                                    

  • Calling stored procedure from within container TX

    Hi
    I am calling a stored procedure that resides locally (Oracle) from within a session
    bean after updating a number of ejb's. The stored procedure works fine if it performs
    a simple delete. However, the stored procedure is in turn calling another stored
    procedure that may reside in a different db. In such a case the update to the
    ejb's in not reflected at all. Is this possible to do this within one tx? BTW
    there is a reason I'm not calling the remote SP directly.
    Thanks

    Hi,
    I am not sure if I fully understand your question, but here is a list of points which you
    should check:
    - transaction boundaries
    - transaction isolation level
    - XA datasources and drivers
    - are the changes from the SP commited properly to the database ?
    - also note that WLS5.1 (if you are using it ?) supports 2 phase commit only with a
    single datasource
    Regards,
    Christian Buchegger
    Developer Relations Engineer
    BEA Support
    Michael schrieb:
    Hi
    I am calling a stored procedure that resides locally (Oracle) from within a session
    bean after updating a number of ejb's. The stored procedure works fine if it performs
    a simple delete. However, the stored procedure is in turn calling another stored
    procedure that may reside in a different db. In such a case the update to the
    ejb's in not reflected at all. Is this possible to do this within one tx? BTW
    there is a reason I'm not calling the remote SP directly.
    Thanks

  • Calling a procedure from within a procedure

    Hi Guys,
    I have created a package to base a form on. The package contains some procedures, one of which is an Update procedure which can be seen below. I have a procedure in another package that I am trying to call. Basically the second procedure is called to implement a constraint. However, I am unsure as to what I should pass into this procedure, as a package/procedure for basing a form on is different to what I have come across before.
    CREATE OR REPLACE package staff_dml IS
    TYPE staff_rec IS RECORD (staff_id NUMBER(7),
              first_name VARCHAR2(20),
              last_name VARCHAR2(20),
              tel_no NUMBER(11),
              manager_id NUMBER(7),
              position VARCHAR2(20),
    rest_id NUMBER(7),
              grade VARCHAR2(1),
              wage NUMBER(7,2));
    TYPE staff_cursor IS REF CURSOR RETURN staff_rec;
    TYPE staff_table IS TABLE OF staff_rec INDEX BY BINARY_INTEGER;
    PROCEDURE staff_update (data IN OUT staff_table);
    PROCEDURE staff_find (data IN OUT staff_cursor);
    PROCEDURE staff_lock (data IN OUT staff_table);
    END;
    CREATE OR REPLACE PACKAGE BODY staff_dml IS
    PROCEDURE staff_lock (data IN OUT staff_table)
    IS
    temp NUMBER;
    BEGIN
    SELECT staff_id into temp
    FROM staff
    WHERE staff_id = data(1).staff_id
    FOR UPDATE;
    END staff_lock;
    PROCEDURE staff_find (data IN OUT staff_cursor)
    IS
    BEGIN
    OPEN data FOR SELECT staff_id, first_name, last_name, tel_no, manager_id, position, rest_id, grade, wage
    FROM staff;
    END staff_find;
    PROCEDURE staff_update
    (data IN OUT staff_table)
    IS
    BEGIN
    IF data(1).wage != data(1).wage THEN
    special_pkg.staff_chk(data(1).wage,data(1).grade);
    END IF;
    IF data(1).grade != data(1).grade THEN
    special_pkg.staff_chk(data(1).wage,data(1).grade);
    END IF;
    UPDATE staff
    SET first_name = data(1).first_name, last_name = data(1).last_name, tel_no = data(1).tel_no, manager_id = data(1).manager_id,
    position = data(1).position, rest_id = data(1).rest_id, grade = data(1).grade, wage = data(1).wage
    WHERE staff_id = data(1).staff_id;
    EXCEPTION
    WHEN OTHERS THEN
    DBMS_OUTPUT.PUT_LINE(SQLCODE||' '||SQLERRM);
    END staff_update;
    END;
    The area I an concerned about is:
    IF data(1).wage != data(1).wage THEN
    special_pkg.staff_chk(data(1).wage,data(1).grade);
    END IF;
    IF data(1).grade != data(1).grade THEN
    special_pkg.staff_chk(data(1).wage,data(1).grade);
    END IF;
    I do not know what I should be passing into the special_pkg.staff_chk procedure which accepts two number inputs. I want to use this package to compare the new inputs on this to the existing ones (this is carried out by the procedure. I have tried using :new. but this is not accepted. If I leave in the EXCEPTION then i get no errors from the form, but it will not save any changes I make on the database. If I remove the EXCEPTION then I get an error from the form - FRM-40735 UPDATE-PROCEDURE trigger raised unhandled exception ORA-04098. I am pretty sure this is because I am not supplying the correct variables to the called procedure,
    The called procedure is below (tested and working):
    PROCEDURE staff_chk
    (p_wage IN NUMBER,
    p_grade IN NUMBER)
    IS
    BEGIN
    IF p_wage BETWEEN 0 AND 7.00 AND p_grade != 'C' THEN
    RAISE_APPLICATION_ERROR(-20002, 'The Incorrect grade has been applied to this employee');
    ELSIF p_wage BETWEEN 7.01 AND 10 AND p_grade != 'B' THEN
    RAISE_APPLICATION_ERROR(-20003, 'The Incorrect grade has been applied to this employee');
    ELSIF p_wage BETWEEN 10.01 AND 20 AND p_grade != 'A' THEN
    RAISE_APPLICATION_ERROR(-20004, 'The Incorrect grade has been applied to this employee');
    END IF;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    DBMS_OUTPUT.PUT_LINE('Staff member does not exist');
    END staff_chk;
    END;
    Any help would be greatly appreciated.
    Thanks,
    Anton

    Since this appears to be an Oracle Forms related question, you may want to pose it over in the Oracle Forms forum.
    Forms
    The folks over there are a lot more likely to be able to solve your problem.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Calling a procedure from within a procedure - dif to post below

    Hi Guys,
    I have created a package to base a form on. The package contains some procedures, one of which is an Update procedure which can be seen below. I have a procedure in another package that I am trying to call. Basically the second procedure is called to implement a constraint. However, I am unsure as to what I should pass into this procedure, as a package/procedure for basing a form on is different to what I have come across before.
    CREATE OR REPLACE package staff_dml IS
    TYPE staff_rec IS RECORD (staff_id NUMBER(7),
    first_name VARCHAR2(20),
    last_name VARCHAR2(20),
    tel_no NUMBER(11),
    manager_id NUMBER(7),
    position VARCHAR2(20),
    rest_id NUMBER(7),
    grade VARCHAR2(1),
    wage NUMBER(7,2));
    TYPE staff_cursor IS REF CURSOR RETURN staff_rec;
    TYPE staff_table IS TABLE OF staff_rec INDEX BY BINARY_INTEGER;
    PROCEDURE staff_update (data IN OUT staff_table);
    PROCEDURE staff_find (data IN OUT staff_cursor);
    PROCEDURE staff_lock (data IN OUT staff_table);
    END;
    CREATE OR REPLACE PACKAGE BODY staff_dml IS
    PROCEDURE staff_lock (data IN OUT staff_table)
    IS
    temp NUMBER;
    BEGIN
    SELECT staff_id into temp
    FROM staff
    WHERE staff_id = data(1).staff_id
    FOR UPDATE;
    END staff_lock;
    PROCEDURE staff_find (data IN OUT staff_cursor)
    IS
    BEGIN
    OPEN data FOR SELECT staff_id, first_name, last_name, tel_no, manager_id, position, rest_id, grade, wage
    FROM staff;
    END staff_find;
    PROCEDURE staff_update
    (data IN OUT staff_table)
    IS
    BEGIN
    IF data(1).wage != data(1).wage THEN
    special_pkg.staff_chk(data(1).wage,data(1).grade);
    END IF;
    IF data(1).grade != data(1).grade THEN
    special_pkg.staff_chk(data(1).wage,data(1).grade);
    END IF;
    UPDATE staff
    SET first_name = data(1).first_name, last_name = data(1).last_name, tel_no = data(1).tel_no, manager_id = data(1).manager_id,
    position = data(1).position, rest_id = data(1).rest_id, grade = data(1).grade, wage = data(1).wage
    WHERE staff_id = data(1).staff_id;
    EXCEPTION
    WHEN OTHERS THEN
    DBMS_OUTPUT.PUT_LINE(SQLCODE||' '||SQLERRM);
    END staff_update;
    END;
    The area I an concerned about is:
    IF data(1).wage != data(1).wage THEN
    special_pkg.staff_chk(data(1).wage,data(1).grade);
    END IF;
    IF data(1).grade != data(1).grade THEN
    special_pkg.staff_chk(data(1).wage,data(1).grade);
    END IF;
    I do not know what I should be passing into the special_pkg.staff_chk procedure which accepts two number inputs. I want to use this package to compare the new inputs on this to the existing ones (this is carried out by the called procedure). I have tried using :new. but this is not accepted. If I leave in the EXCEPTION then i get no errors from the form, but it will not save any changes I make on the database. If I remove the EXCEPTION then I get an error from the form - FRM-40735 UPDATE-PROCEDURE trigger raised unhandled exception ORA-04098. I am pretty sure this is because I am not supplying the correct variables to the called procedure,
    The called procedure is below (tested and working):
    PROCEDURE staff_chk
    (p_wage IN NUMBER,
    p_grade IN NUMBER)
    IS
    BEGIN
    IF p_wage BETWEEN 0 AND 7.00 AND p_grade != 'C' THEN
    RAISE_APPLICATION_ERROR(-20002, 'The Incorrect grade has been applied to this employee');
    ELSIF p_wage BETWEEN 7.01 AND 10 AND p_grade != 'B' THEN
    RAISE_APPLICATION_ERROR(-20003, 'The Incorrect grade has been applied to this employee');
    ELSIF p_wage BETWEEN 10.01 AND 20 AND p_grade != 'A' THEN
    RAISE_APPLICATION_ERROR(-20004, 'The Incorrect grade has been applied to this employee');
    END IF;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    DBMS_OUTPUT.PUT_LINE('Staff member does not exist');
    END staff_chk;
    END;
    Any help would be greatly appreciated.
    Thanks,
    Anton

    Hi,
    You triggered in fired on table and you procedure in acting is on the same table which rasing the exception.
    Go throw this link you will understand
    http://asktom.oracle.com/tkyte/Mutate/
    - Pavan Kumar N

  • Calling a concurrent request from within the trigger

    Oracle apps r12.
    Calling a concurrent request from within the trigger.
    Does it requre apps initilization.
    Thanks,
    Lavan

    Hi,
    Whether apps initialization needed or not will depend on followings
    1. Trigger is written on which table seeded or custom. In case of seeded tables, there is no need for apps initialization (although oracle does not recommend writing trigger on seeded tables).
    2. Triggering Table Update/Insert/Delete event processing is done from apps front end or Backend. In case of front end apps initialization is not required.
    Regards,
    Saurabh

  • Can we call a procedure from  a trigger

    Can we call a procedure from a trigger
    thanks

    Why cant you test yourself..?
    SQL> ed
    Wrote file afiedt.buf
      1  create or replace procedure p1
      2  as
      3  begin
      4   null;
      5* end;
    SQL> /
    Procedure created.
    SQL> ed
    Wrote file afiedt.buf
      1  create or replace trigger t1
      2  after insert on t
      3  begin
      4   p1;
      5* end;
    SQL> /
    Trigger created.
    SQL> insert into t
      2  values(5,'n');
    1 row created.
    Message was edited by:
            jeneesh                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Call Stored Procedure inside a db trigger

    Is that possible to call stored procedure inside a db trigger ?
    I User this code:
    Create Or Replace Trigger Sale.Send_Auto_Email_Trg
    After Insert
    On Sale.Sale_Technical_Support
    --Referencing New As New Old As Old
    For Each Row
    Declare
    Pragma Autonomous_Transaction;
    vn_count         Number := 0;
    vn_msg           Number;
    vv_exec          Varchar2(5000);
    Begin
      If Inserting And :New.Ticket_Status = 2 Then
       Begin
        Begin
         Select Count(*)
           Into vn_count
           From Sale_Technical_Support
          Where Sending_Flag = 1
            And Support_Type = 2;
        Exception When No_Data_Found Then
         vn_count := 0;
        End;
        If vn_count >= 1 And :New.Problem_Desc Is Not Null Then
         Technical_Support_Mailing('[email protected]',  -- To
                                   '[email protected]',
                                   '[email protected]',  -- Bcc
                                   '[email protected]',  -- From
                                   'رموز وصلاحيات',
                                   2);                                                                                          
        End If;
       End;
      End If;
    End;
    /No errors but the procedure doesn't executed !!!!!

    1) If you are using autonomous transactions for anything other that writing log data that you want to preserve even if the triggering transaction fails, you're probably doing something wrong. There is no reason to use an autonomous transaction here.
    2) You don't want to send email from a trigger. You don't want to do anything non-transactional in a trigger. Oracle will, for example, rollback and re-execute parts of a statement for write consistency. If you send email in a trigger, you may get multiple emails for a single update. You may also get emails for updates that were never committed. And if the email server happens to be down, your transactions will fail.
    3) If you use an autonomous transaction, the trigger will have a completely different transaction context from the parent. So when you query the table within the trigger, you won't be able to see any of the uncommitted changes including the changes that caused the trigger to fire. My guess is that you are assuming that the row that you inserted is visible to the trigger.
    Justin

  • Is it possible to fire DDL queries from within a trigger?

    Hi,
    In Oracle 8.0.5, Is it possible to fire DDL queries from within a trigger?
    e.g. when no. of rows is multiple of 1000, I wish to call a procedure which
    analyzes the table and finds the size of the table. I am getting :
    "ORA-04092: cannot COMMIT in a trigger" error message.
    Regards
    Sanchayan

    One way around this is to use the AUTONOMOUS_TRANSACTION pragma, but I think that was introduced in 8i. Check your docs. Another way is to set up a procedure to do the ANALYZE and in your trigger submit a job using DBMS_JOB to run that procedure.
    Anyway, the second option is best because you really don't want to impose the overhead of running an ANALYZE onto a DML transaction.
    You are also going to run into the mutating table problem: you can't find out how big the table is, because you can't run queries against the table from within a trigger. You could use DATE_LAST_ANALYZED from USER_TAB_COLUMNS, but really you should just schedule jobs to run ANALAYZE at regular intervals - once a day, once a week, once a month, depending on the volatility and usage of any given table.
    Cheers, APC

  • PL/SQL: Executing a procedure from within another procedure

    Hello, I'm a newbie and I need help on how to execute procedures from within another procedure. The procedure that I call from within the procedure have return values that I want to check.
    I tried: EXECUTE(user_get_forum_info(p_forumid, var_forum_exists, var_forum_access, var_forumname));
    but I get the error message:
    PLS-00103: Encountered the symbol "USER_GET_FORUM_INFO" when expecting one of the following::= . ( @ % ; immediate
    The symbol ":=" was substituted for "USER_GET_FORUM_INFO" to continue.
    And when I tried: EXECUTE(user_get_forum_info(p_forumid, var_forum_exists, var_forum_access, var_forumname));
    I get the error message:
    PLS-00222: no function with name 'USER_GET_FORUM_INFO' exists in this scope
    PL/SQL: Statement ignored
    The procedure USER_GET_FORUM_INFO exists. (don't understand why it says "no FUNCTION with name", it's a procedure I'm executing)
    I'm stuck so thanks for any help...
    Below is all the code. I'm using Oracle 9i on RedHat Linux 7.3.
    ================================================================================
    CREATE OR REPLACE PROCEDURE user_forum_requestsaccess (
    p_forumid IN NUMBER,
    p_requestmessage IN VARCHAR2
    AS
    var_forumid NUMBER;
    var_forum_exists NUMBER;
    var_forum_access NUMBER;
    request_exists NUMBER;
    var_forumname VARCHAR2(30);
    FORUM_DOESNT_EXIST EXCEPTION;
    FORUM_USER_HAS_ACCESS EXCEPTION;
    FORUM_REQUEST_EXIST EXCEPTION;
    BEGIN
    SELECT SIGN(NVL((SELECT request_id FROM forum.vw_all_forum_requests WHERE forum_id = p_forumid AND db_user = user),0)) INTO request_exists FROM DUAL;
    EXECUTE(user_get_forum_info(p_forumid, var_forum_exists, var_forum_access, var_forumname));
    IF var_forum_exists = 0 THEN
    RAISE FORUM_DOESNT_EXIST;
    ELSIF var_forum_access = 1 THEN
    RAISE FORUM_USER_HAS_ACCESS;
    ELSIF request_exists = 1 THEN
    RAISE FORUM_REQUEST_EXIST;
    ELSE
    INSERT INTO tbl_forum_requests VALUES (SEQ_TBL_FORUM_REQ_REQ_ID.NEXTVAL, SYSDATE, p_requestmessage, p_forumid, user);
    INSERT INTO tbl_forum_eventlog VALUES (SEQ_TBL_FORUM_EVNTLOG_EVNT_ID.NEXTVAL,SYSDATE,1,'User ' || user || ' requested access to forum ' || var_forumname || '.', p_forumid,user);
    COMMIT;
    END IF;
    EXCEPTION
    WHEN
    FORUM_DOESNT_EXIST
    THEN RAISE_APPLICATION_ERROR(-20003,'Forum doesnt exist.');
    WHEN
    FORUM_USER_HAS_ACCESS
    THEN RAISE_APPLICATION_ERROR(-20004,'User already have access to this forum.');
    WHEN
    FORUM_REQUEST_EXIST
    THEN RAISE_APPLICATION_ERROR(-20005,'A request to this forum already exist.');
    END;
    GRANT EXECUTE ON user_forum_requestsaccess TO forum_user;
    ================================================================================
    Regards Goran

    you don't have to use execute when you want to execute a procedure (only on sql*plus, you would use it)
    just give the name of the funtion
    create or replace procedure test
    as
    begin
        dbms_output.put_line('this is the procedure test');
    end test;
    create or replace procedure call_test
    as
    begin
        dbms_output.put_line('this is the procedure call_test going to execute the procedure test');
        test;
    end call_test;
    begin
        dbms_output.put_line('this is an anonymous block calling the procedure call_test');
        call_test;
    end;
    /

  • Unable to call a procedure from inside a another procedure

    Dear members
    I am trying to call a procedure from inside an another procedure.Both the procedures are present within the same package.I am trying to call the second procedure just before the end of the first procedure.Both the procedures are compiling fine but the tables are not getting populated inside the second procedure.Also the DBMS_OUTPUT statements present in second procedures are not getting displayed.(I feel the second procedured is not getting called).
    The package specification is as follows:
    CREATE OR REPLACE package ANVESH.conv_api_pkg
    is
        PROCEDURE PROC_CONVERSION_API(FILE_PATH IN VARCHAR2,FILE_NAME IN VARCHAR2) ;
        TYPE cts_order_details IS TABLE OF XXCTS_ORDER_DETAILS_STG%ROWTYPE;
        PROCEDURE proc_conversion_api2(p_orderdetails IN cts_order_details) ;
    end conv_api_pkg;The package body is as follows:
    CREATE OR REPLACE package body ANVESH.conv_api_pkg
    is
    PROCEDURE PROC_CONVERSION_API(FILE_PATH IN VARCHAR2,FILE_NAME IN VARCHAR2)
    IS
        v_file_type utl_file.file_type;
        v_buffer VARCHAR2(1000);
        V_CUSTOMER_NAME VARCHAR2(100);
        V_MANUFACTURER VARCHAR2(100);
        V_PRODUCT_NAME VARCHAR2(100);
        V_QUANTITY NUMBER;
        V_REQ_SHIP_DATE DATE;
        V_REQ_PRICE NUMBER;
        V_LOG_FILE utl_file.file_type;
        V_COUNT_CUST NUMBER;
        V_COUNT_PROD NUMBER;
       L_ORDER_LINES CONV_API_PKG.cts_order_details:=CONV_API_PKG.cts_order_details();
    BEGIN
        DBMS_OUTPUT.PUT_LINE('Inside begin 1');
        v_file_type := UTL_FILE.fopen(FILE_PATH, FILE_NAME, 'r',null);
            DBMS_OUTPUT.PUT_LINE('Inside begin 1.1');
        LOOP
            BEGIN
                        DBMS_OUTPUT.PUT_LINE('Inside begin 2');
                         UTL_FILE.GET_LINE (v_file_type,v_buffer);
                        DBMS_OUTPUT.PUT_LINE('Inside begin 2.1');
                        DBMS_OUTPUT.PUT_LINE('the  buffer is '||v_buffer);
                        DBMS_OUTPUT.PUT_LINE('the length of buffer is '||length(v_buffer));
                         V_CUSTOMER_NAME := trim(substr(v_buffer, 1, 30));
                         DBMS_OUTPUT.PUT_LINE('Customer Name is '||V_CUSTOMER_NAME);
                         V_MANUFACTURER  := trim(substr(v_buffer, 31, 40));
                         DBMS_OUTPUT.PUT_LINE('Manufacturer is '||V_MANUFACTURER);
                         V_PRODUCT_NAME  := trim(substr(v_buffer,  71, 20));
                         DBMS_OUTPUT.PUT_LINE('Product Name is '||V_PRODUCT_NAME);
                         V_QUANTITY      := to_number(trim(substr(v_buffer, 91, 5)));
                         DBMS_OUTPUT.PUT_LINE('Quantity is '||V_QUANTITY);
                         V_REQ_SHIP_DATE     := to_date(trim(substr(v_buffer, 96, 20)), 'DD-MON-YYYY');
                         DBMS_OUTPUT.PUT_LINE('Requested Ship Date is '|| V_REQ_SHIP_DATE);
                        V_REQ_PRICE        :=nvl(substr( trim(v_buffer), 116, length(v_buffer)-116),0);
                        --DBMS_OUTPUT.PUT_LINE('Requested Price is1 '||substr(v_buffer, 116, 5));
                        DBMS_OUTPUT.PUT_LINE('The requested price is  '||V_REQ_PRICE);
                V_LOG_FILE := UTL_FILE.FOPEN(FILE_PATH, 'LOG_FILE.dat', 'A');
                    IF (V_QUANTITY > 0)
                     THEN
                     DBMS_OUTPUT.PUT_LINE('The quantity is '||V_QUANTITY);
                       SELECT COUNT (*)
                       INTO V_COUNT_CUST
                       FROM CONVERSION_CUSTOMERS
                       WHERE CUSTOMER_NAME = V_CUSTOMER_NAME;
                       DBMS_OUTPUT.PUT_LINE('The Customer count is '||V_COUNT_CUST);
                       IF(V_COUNT_CUST > 0)
                       THEN
                           SELECT COUNT(*)
                           INTO V_COUNT_PROD
                           FROM conversion_products
                           WHERE PRODUCT_NAME = V_PRODUCT_NAME;
                           DBMS_OUTPUT.PUT_LINE('The Product count is '||V_COUNT_PROD);
                          IF(V_COUNT_PROD >0)
                           THEN
                                INSERT INTO XXCTS_ORDER_DETAILS_STG VALUES (V_CUSTOMER_NAME, V_PRODUCT_NAME, V_MANUFACTURER, V_QUANTITY, V_REQ_SHIP_DATE, V_REQ_PRICE, 'ACTIVE', 'ORDER TAKEN');  
                           ELSE
                                DBMS_OUTPUT.PUT_LINE('PRODUCT SHOULD BE VALID');
                                UTL_FILE.PUT_LINE(V_LOG_FILE, 'PRODUCT SHOULD BE VALID');                   
                           END IF;
                       ELSE
                          DBMS_OUTPUT.PUT_LINE('CUSTOMER SHOULD BE VALID');
                          UTL_FILE.PUT_LINE(V_LOG_FILE, 'CUSTOMER SHOULD BE VALID');
                       END IF;      
                    ELSE
                        DBMS_OUTPUT.PUT_LINE('QUANTITY SHOULD BE VALID');
                        UTL_FILE.PUT_LINE(V_LOG_FILE, 'QUANTITY SHOULD BE VALID');
                    END IF;
                    EXCEPTION
                    WHEN NO_DATA_FOUND THEN
                        EXIT;
                    END;
        END LOOP;
    SELECT CUSTOMER_NAME, PRODUCT_NAME, MANUFACTURER, QUANTITY, REQUESTED_SHIP_DATE, REQUESTED_PRICE, STATUS,MESSAGE
    BULK COLLECT
    INTO L_ORDER_LINES
    FROM XXCTS_ORDER_DETAILS_STG;
    DBMS_OUTPUT.PUT_LINE('values inserted');
    proc_conversion_api2(p_orderdetails=>L_ORDER_LINES);
    END;
    PROCEDURE proc_conversion_api2(p_orderdetails IN cts_order_details)
      IS
      V_AVL_QUANTITY CONVERSION_PRODUCTS.AVL_QUANTITY%TYPE;
      V_REQ_SHIP_DATE DATE;
      V_LIST_PRICE CONVERSION_PRODUCTS.LIST_PRICE%TYPE;
      V_NET_PRICE CONVERSION_PRODUCTS.LIST_PRICE%TYPE;
      V_NET CONVERSION_PRODUCTS.LIST_PRICE%TYPE;
      V_EXTN_PRICE CONVERSION_PRODUCTS.LIST_PRICE%TYPE;
      V_CUST_DISC CONVERSION_CUSTOMERS.DISCOUNT%TYPE;
      V_CERT_DISC CONVERSION_CERTIFICATION.DISCOUNT%TYPE;
      V_CUST_ID XXCTS_ORDER_DETAILS.CUSTOMER_ID%TYPE;
      V_PROD_ID XXCTS_ORDER_DETAILS.PRODUCT_ID%TYPE;
      V_DISC_PRICE CONVERSION_PRODUCTS.LIST_PRICE%TYPE;
      V_DISC_NAME CONVERSION_CERTIFICATION.CERTIFICATION%TYPE;
      V_TOTAL_DISC_AMT NUMBER;
      V_TOTAL_DISC NUMBER;
      V_LIMIT NUMBER;
    BEGIN
        DBMS_OUTPUT.PUT_LINE('INSIDE API_2 BEGIN 1');
            FOR i IN p_orderdetails.FIRST..p_orderdetails.LAST
            LOOP
                 BEGIN
                DBMS_OUTPUT.PUT_LINE('INSIDE API_2 BEGIN 2');
                SELECT PRODUCT_ID,AVL_QUANTITY,LIST_PRICE
                INTO V_PROD_ID,V_AVL_QUANTITY,V_LIST_PRICE
                FROM CONVERSION_PRODUCTS
                WHERE PRODUCT_NAME=p_orderdetails(i).PRODUCT_NAME;
                DBMS_OUTPUT.PUT_LINE('PRODUCT QUANTITY is '||V_PROD_ID);
                DBMS_OUTPUT.PUT_LINE('AVAILABLE QUANTITY is '||V_AVL_QUANTITY);
                DBMS_OUTPUT.PUT_LINE('LIST PRICE is '||V_LIST_PRICE);
                SELECT CUSTOMER_ID,NVL(DISCOUNT,0)
                INTO V_CUST_ID,V_CUST_DISC
                FROM CONVERSION_CUSTOMERS
                WHERE CUSTOMER_NAME=p_orderdetails(i).CUSTOMER_NAME;
                DBMS_OUTPUT.PUT_LINE('CUSTOMER ID is '||V_CUST_ID);
                DBMS_OUTPUT.PUT_LINE('CUSTOMER DISCOUNT IS '||V_CUST_DISC);
                SELECT A.DISCOUNT,A.CERTIFICATION
                INTO  V_CERT_DISC,V_DISC_NAME
                FROM CONVERSION_CERTIFICATION A,CONVERSION_CUSTOMERS B
                WHERE A.CERTIFICATION=B.CERTIFICATION(+)
                AND B.CUSTOMER_NAME=p_orderdetails(i).CUSTOMER_NAME;
                DBMS_OUTPUT.PUT_LINE('CERTIFICATION DISCOUNT IS '||V_CERT_DISC);
                V_NET:=((V_LIST_PRICE)-(V_LIST_PRICE)*(V_CERT_DISC)/100);
                DBMS_OUTPUT.PUT_LINE('NET PRICE AFTER CERTIFICATION DISCOUNT IS '||V_NET);
                V_NET_PRICE:=((V_NET)-(V_NET)*(V_CUST_DISC)/100);
                DBMS_OUTPUT.PUT_LINE('NET PRICE AFTER COMPLETE DISCOUNT IS '||V_NET_PRICE);
                V_EXTN_PRICE:=(V_NET_PRICE)*(p_orderdetails(i).QUANTITY);
                DBMS_OUTPUT.PUT_LINE('EXTENDED PRICE IS '||V_EXTN_PRICE);
                V_TOTAL_DISC:=((V_CERT_DISC)/100+(V_CUST_DISC)/100);
                DBMS_OUTPUT.PUT_LINE('TOTAL DISCOUNT IS '|| V_TOTAL_DISC);
                V_TOTAL_DISC_AMT:=(V_LIST_PRICE)-(V_NET_PRICE);
                DBMS_OUTPUT.PUT_LINE('TOTAL DISCOUNT PRICE IS '|| V_TOTAL_DISC_AMT);
                SELECT MAX(A.LIMIT)
                INTO V_LIMIT
                FROM CONVERSION_CERTIFICATION A,CONVERSION_CUSTOMERS B
                WHERE A.CERTIFICATION=B.CERTIFICATION(+)
                AND B.CUSTOMER_NAME=p_orderdetails(i).CUSTOMER_NAME;
                IF p_orderdetails(i).QUANTITY<V_AVL_QUANTITY THEN
                INSERT INTO XXCTS_ORDER_DETAILS VALUES(SEQ_HEADER_ID.NEXTVAL,SEQ_LINE_ID.NEXTVAL,V_CUST_ID,V_PROD_ID,p_orderdetails(i).QUANTITY,p_orderdetails(i).REQUESTED_SHIP_DATE,p_orderdetails(i).REQUESTED_PRICE,V_LIST_PRICE,V_TOTAL_DISC,V_NET_PRICE,V_EXTN_PRICE,'QTY HOLD','REQ QNTY LESS THAN AVL QTY',SYSDATE);
                INSERT INTO xxcts_order_discounts VALUES(SEQ_HEADER_ID.NEXTVAL,SEQ_LINE_ID.NEXTVAL,SEQ_DISCOUNT_ID.NEXTVAL,V_DISC_NAME,V_TOTAL_DISC_AMT);
                END IF;
                IF p_orderdetails(i).REQUESTED_SHIP_DATE<SYSDATE THEN
                INSERT INTO XXCTS_ORDER_DETAILS VALUES(SEQ_HEADER_ID.NEXTVAL,SEQ_LINE_ID.NEXTVAL,V_CUST_ID,V_PROD_ID,p_orderdetails(i).QUANTITY,p_orderdetails(i).REQUESTED_SHIP_DATE,p_orderdetails(i).REQUESTED_PRICE,V_LIST_PRICE,V_TOTAL_DISC,V_NET_PRICE,V_EXTN_PRICE,'DATE HOLD','SHIPDATE CANNOT BE LESS THAN CURR DATE',SYSDATE);
                INSERT INTO xxcts_order_discounts VALUES(SEQ_HEADER_ID.NEXTVAL,SEQ_LINE_ID.NEXTVAL,SEQ_DISCOUNT_ID.NEXTVAL,V_DISC_NAME,V_TOTAL_DISC_AMT);
                END IF;
                IF V_NET_PRICE>p_orderdetails(i).REQUESTED_PRICE THEN
                INSERT INTO XXCTS_ORDER_DETAILS VALUES(SEQ_HEADER_ID.NEXTVAL,SEQ_LINE_ID.NEXTVAL,V_CUST_ID,V_PROD_ID,p_orderdetails(i).QUANTITY,p_orderdetails(i).REQUESTED_SHIP_DATE,p_orderdetails(i).REQUESTED_PRICE,V_LIST_PRICE,V_TOTAL_DISC,V_NET_PRICE,V_EXTN_PRICE,'PRICE HOLD','NET PRICE CANNOT BE MORE THAN REQ PRICE',SYSDATE);
                INSERT INTO xxcts_order_discounts VALUES(SEQ_HEADER_ID.NEXTVAL,SEQ_LINE_ID.NEXTVAL,SEQ_DISCOUNT_ID.NEXTVAL,V_DISC_NAME,V_TOTAL_DISC_AMT);
                END IF;
               /* IF V_LIMIT<p_orderdetails(i).REQUESTED_PRICE THEN
                INSERT INTO XXCTS_ORDER_DETAILS VALUES(SEQ_HEADER_ID.NEXTVAL,SEQ_LINE_ID.NEXTVAL,V_CUST_ID,V_PROD_ID,p_orderdetails(i).QUANTITY,p_orderdetails(i).REQUESTED_SHIP_DATE,p_orderdetails(i).REQUESTED_PRICE,V_LIST_PRICE,V_TOTAL_DISC,V_NET_PRICE,V_EXTN_PRICE,'ORDER LIMIT HOLD','PRICE CANNOT EXCEED ORDER LIMIT',SYSDATE);
                INSERT INTO xxcts_order_discounts VALUES(SEQ_HEADER_ID.NEXTVAL,SEQ_LINE_ID.NEXTVAL,SEQ_DISCOUNT_ID.NEXTVAL,V_DISC_NAME,V_TOTAL_DISC_AMT);
                END IF;*/
                EXCEPTION
                WHEN NO_DATA_FOUND THEN
                DBMS_OUTPUT.PUT_LINE(' INSIDE EXCEPTION BLOCK');
                END;
            END LOOP;
    END;
    end conv_api_pkg;
    /the pl/sql block to invoke the the procedure :
    declare
    begin
    PROC_CONVERSION_API('/usr/tmp' ,'Walmart_Orders_062908.dat');
    end;please let me know what is wrong in the program.
    Thanks
    Anvesh

    Hi Walter
    Yes 'Inside begin 1' and 'Inside begin 2' were printed.Please find the the DBMS_OUTPUT statements that were printed.
    Inside begin 1
    Inside begin 1.1
    Inside begin 2
    Inside begin 2.1
    the  buffer is BESTBUY                       SONY ERICSSON                           W580i               25   1-AUG-2008          50
    the length of buffer is 118
    Customer Name is BESTBUY
    Manufacturer is SONY ERICSSON
    Product Name is W580i
    Quantity is 25
    Requested Ship Date is 01-AUG-08
    The requested price is  50
    The quantity is 25
    The Customer count is 1
    The Product count is 0
    PRODUCT SHOULD BE VALID
    Inside begin 2
    Inside begin 2.1
    the  buffer is BESTBUY                       SAMSUNG                                 BLACKJACK           50   15-JUL-2008         150
    the length of buffer is 119
    Customer Name is BESTBUY
    Manufacturer is SAMSUNG
    Product Name is BLACKJACK
    Quantity is 50
    Requested Ship Date is 15-JUL-08
    The requested price is  150
    The quantity is 50
    The Customer count is 1
    The Product count is 1
    Inside begin 2
    Inside begin 2.1
    the  buffer is BESTBUY                       APPLE                                   IPHONE 4GB          50   15-JUL-2008        
    the length of buffer is 116
    Customer Name is BESTBUY
    Manufacturer is APPLE
    Product Name is IPHONE 4GB
    Quantity is 50
    Requested Ship Date is 15-JUL-08
    The requested price is  0
    The quantity is 50
    The Customer count is 1
    The Product count is 1
    Inside begin 2
    Inside begin 2.1
    the  buffer is BESTBUY                       ATT                                     TILT                100  15-JUN-2008        
    the length of buffer is 116
    Customer Name is BESTBUY
    Manufacturer is ATT
    Product Name is TILT
    Quantity is 100
    Requested Ship Date is 15-JUN-08
    The requested price is  0
    The quantity is 100
    The Customer count is 1
    The Product count is 1
    Inside begin 2
    Inside begin 2.1
    the  buffer is BESTBUY                       NOKIA                                   N73                 50   15-JUL-2008         200
    the length of buffer is 118
    Customer Name is BESTBUY
    Manufacturer is NOKIA
    Product Name is N73
    Quantity is 50
    Requested Ship Date is 15-JUL-08
    The requested price is  20
    The quantity is 50
    The Customer count is 1
    The Product count is 0
    PRODUCT SHOULD BE VALID
    Inside begin 2In the first procedure I am trying to read the data from a flat file and store it in a table.Here is the sample data from the flat file.
    BESTBUY                       SONY ERICSSON                           W580i               25   1-AUG-2008          50
    BESTBUY                       SAMSUNG                                 BLACKJACK           50   15-JUL-2008         150
    BESTBUY                       APPLE                                   IPHONE 4GB          50   15-JUL-2008        
    BESTBUY                       ATT                                     TILT                100  15-JUN-2008        
    BESTBUY                       NOKIA                                   N73                 50   15-JUL-2008         200When tried to execute the second procedure independently using the PL/SQL block,the tables in second procedure were populated and the DBMS_Output statements were also displayed.I have made use of the same query in that case
    Thanks
    Anvesh
    Edited by: Anvesh Reddy on Dec 23, 2008 12:40 PM

  • How to use @jws:sql call Stored Procedure from Workshop

    Is there anyone know how to use @jws tag call Sybase stored procedure within
    Workshop,
    Thanks,

    Anurag,
    Do you know is there any plan to add this feature in future release? and
    when?
    Thanks,
    David
    "Anurag Pareek" <[email protected]> wrote in message
    news:[email protected]..
    David,
    In the current release, we do not support calling stored procedures from a
    database control. You will have to write JDBC code in the JWS file to call
    stored procedures.
    Regards,
    Anurag
    Workshop Support
    "David Yuan" <[email protected]> wrote in message
    news:[email protected]..
    Anurag,
    I know how to use DB connection pool and create a db control with it. In
    fact, we have created a Web Service with the db control using plain SQL
    in
    @jws:sql. However, my question here is how to use @jws tag in Weblogic
    Workshop to create a Web Services based on Sybase stored procedure orany
    Stored Proc not plain SQL.
    Thanks,
    David
    "Anurag Pareek" <[email protected]> wrote in message
    news:[email protected]..
    David,
    You can use a database control to obtain a connection from any JDBC
    Connection Pool configured in the config.xml file. The JDBC Connectionpool
    could be connecting to any database, the database control is
    independent
    of
    that.
    Regards,
    Anurag
    Workshop Support
    "David Yuan" <[email protected]> wrote in message
    news:[email protected]..
    Is there anyone know how to use @jws tag call Sybase stored
    procedure
    within
    Workshop,
    Thanks,

  • How to call a package from within a package

    How would I call a package from within a package and pass variables to it. For instance I am trying to pass variables to a log package from another package when a user inserts or updates a table

    First, technical questions need to be addressed to one of the technical forums. Products | Database | SQL & PL/SQL would be appropriate for this question. Please direct any followup to that forum.
    Second, you cannot call a package; a package is a collection of stored procedures and functions. You can call a packaged function or procedure from another package simply by specifying the package name and the procedure
    CREATE OR REPLACE PACKAGE pkgA
    AS
      PROCEDURE callPkgB;
    END;
    CREATE OR REPLACE PACKAGE BODY pkgA
    AS
      CREATE PROCEDURE callPkgB
      AS
      BEGIN
        pkgB.someProcedure( 'Some argument' );
      END callPkgB;
    END pkgA;In general, any packaged procedure can be called by specifying the schema, package, and procedure name, i.e.
    EXEC mySchema.myPackage.myProcedurethough the schema and package can be omitted if the calling procedure is in the same schema or package.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Error while calling a procedure from ESB

    Hi,
    I am calling a procedure from ESB using DB adapter. and in the routing rules i am mapping the i/p values for schema to procedure input variables using mappings(transformation) but the values are going as null to the procedure call.
    Please help me out.
    The exception follows...
    An unhandled exception has been thrown in the ESB system. The exception reported is: "org.collaxa.thirdparty.apache.wsif.WSIFException: esb:///ESB_Projects/ESB-Issues_issue3/db3.wsdl [ db3_ptt::db3(InputParameters,OutputParameters) ] - WSIF JCA Execute of operation 'db3' failed due to: Error while trying to prepare and execute an API.
    An error occurred while preparing and executing the SYSTEM.INSERT_ISSUE_PROC API. Cause: java.sql.SQLException: ORA-01400: cannot insert NULL into ("SYSTEM"."ISSUES"."ISSUE_NAME")
    ORA-06512: at "SYSTEM.INSERT_ISSUE_PROC", line 16
    ORA-06512: at line 1
    [Caused by: ORA-01400: cannot insert NULL into ("SYSTEM"."ISSUES"."ISSUE_NAME")
    ORA-06512: at "SYSTEM.INSERT_ISSUE_PROC", line 16                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    This is likely being caused by a problem that we've seen a number of times. You'll have namespace issues and problems with NULLs if your JDev is 10.1.3.1 and SOA is 10.1.3.3 (or vice-versa). You MUST synchronize JDev 10.1.3.3 (or higher) with SOA 10.1.3.3 (or higher). It doesn't matter if you mix 10.1.3.3 and 10.1.3.4. You just need to get away from 10.1.3.1.

  • Error when calling a procedure from my apex application

    Hello.
    I want to create a small APEX application that can configure asynchronous change data capture (distributed hotlog) on certain tables.
    Basically, what the application should do is to simply create change tables. Everything else is set up as prerequisite.
    My problem is that when I run the following script from schema apex_cdd (using sqldeveloper) , it works; but if I run it from my apex application by calling it when pressing a button as a pl/sql process, it doen't work.
    BEGIN
    apex_cdc.enable_table_capture
         (     i_owner => 'staging_cdcpub',
              i_change_table_name     => 'g_changeTable',
              i_change_set_name     => 'Source_changeSet',
              i_change_source          => 'orcl01_cs',
              i_source_schema          => 'My_src',
              i_source_table          => 'G',
              i_column_type_list     => 'STARTDATE DATE,STATUS CHAR(1),NAME VARCHAR2(10),ENDDATE DATE,DESCRIPTION VARCHAR2(255),ID NUMBER(8,0),VALUE NUMBER(10,2)'
    END;
    If I look in the trace file, i see that the error is:
    CDCdebug:in ChangeTable.java enableDisabledTriggers: ORA-06550: line 1, column 8:
    PLS-00201: identifier 'SYS.DBMS_CDC_SYS_IPUBLISH' must be declared
    ORA-06550: line 1, column 8:
    PL/SQL: Statement ignored
    oracle.jdbc.driver.OracleSQLException: ORA-06550: line 1, column 8:
    PLS-00201: identifier 'SYS.DBMS_CDC_SYS_IPUBLISH' must be declared
    ORA-06550: line 1, column 8:
    PL/SQL: Statement ignored
    Other remarks:
    - My procedure calls: sys.DBMS_CDC_PUBLISH.CREATE_CHANGE_TABLE.
    - I gave the same rights that I gave for apex_cdc schema to flows_030200 and APEX_PUBLIC_USER schemas (just to see if it works), but it doens't.
    Is APEX calling the procedure from another schema ?
    Does anyone has an idea why this procedure crashes if called from APEX application, but works ok if called from the same schema APEX application runs on, but using SQLDeveloper ?
    Any thoughts are appreciated.
    Radian

    The procedure apex_cdc.enable_table_capture i created myself with no authid mentioned explicitly, so it uses definer rights, by default.
    BUt this procedure is simply a wrapper for sys.dbms_cdc_publish.create_change_table.
    When I look on the security model for this sys.dbms_cdc_publish, i see it runs under invoker rights. (http://www.psoug.org/reference/dbms_cdc_publish.html).
    The code is like this:
    CREATE OR REPLACE PROCEDURE enable_table_capture
              i_owner               IN VARCHAR2,
              i_change_table_name     IN VARCHAR2,
              i_change_set_name     IN VARCHAR2,
              i_change_source          IN VARCHAR2,
              i_source_schema          IN VARCHAR2,
              i_source_table          IN VARCHAR2,
              i_column_type_list     IN VARCHAR2
         IS
         BEGIN
              EXECUTE IMMEDIATE 'alter session set REMOTE_DEPENDENCIES_MODE=SIGNATURE';
              EXECUTE IMMEDIATE 'begin add_log@orcl01(i_tableName => ''G''); end;';
    sys.DBMS_CDC_PUBLISH.CREATE_CHANGE_TABLE(
    owner => i_owner,
    change_table_name => i_change_table_name,
    change_set_name => i_change_set_name,
    source_schema => i_source_schema,
    source_table => i_source_table,
    column_type_list => i_column_type_list,
    capture_values => 'both',
    rs_id => 'y',
    row_id => 'n',
    user_id => 'n',
    timestamp => 'y',
    object_id => 'n',
    source_colmap => 'n',
    target_colmap => 'y',
    options_string => NULL);
    END enable_table_capture;

Maybe you are looking for

  • I accidently deleted iphoto; how do I get it back for free?

    I accidently deleted iphoto; how do I get it back for free?

  • How to put back html tags

    Hi, I have a program that reads an html file, parses the html tags, now I execute code, and then would like to append the original file with my results... How would I put back in the html code that I parsed out? Or would I have to go through it & sea

  • Lens Profile changes in ACR 6.2 update

    Before the update, I had perfectly aligned masks for hundreds of images using the Nikon 18-200mm lens.  However, when I now open their Smart Objects, make and change and close, a new distortion correction is being applied, ie. the masks are not longe

  • Servlet - button redirecton question! pls help

    I have a servlet and i have this button code output.println("<INPUT type='submit' name='pVisits' value='Last Visits'>");I would like to know when i push that button how do i open another servlet to a new page. Another servlet contains code to display

  • 11.5.10 Consolidated Update I has released

    Just want to tell others that this 900mb update for 11i10 has released...I'm so tired of keep patching and upgrading it....