OUT Params in Procedure. Oracle 9

I am new to PL/SQl, and im doing an asp .net site connectin to oracle using ODP
I have written an procedure to take in Params and add a record to a DB, however I now want to use an OUT Param which will return a value to detemine whether the record already exists, this is my procedure, as you can see i have added an INOUT var called pv_exists, i want to check for the input records in my DB, is they exist i want the pv_exists to return a Zero to be site, any ideeas, im at a loss?
CREATE OR REPLACE PROCEDURE HR_USER."SP_ADDPR" (pv_prtype varchar2, pv_team number,pv_year varchar2, pv_month varchar2, pv_alert date, pv_exists IN OUT number )
IS
pv_rowCount number;
pv_tblid number;
pv_text number;
BEGIN
select Count(*) Into pv_rowCount from TBLPR;
if pv_rowCount > 0 then
select Max(ID) + 1 into pv_tblid from TBLPR;
Insert into TBLPR(id,PRType,PRTeamid,PRYEAR,PRMONTH,PRALERTDATE) Values (pv_tblid,pv_prtype,pv_team,pv_year,pv_month,pv_alert);
else
Insert into TBLPR(id,PRType,PRTeamid,PRYEAR,PRMONTH,PRALERTDATE) Values (1,pv_prtype,pv_team,pv_year,pv_month,pv_alert);
end if;
EXCEPTION
WHEN NO_DATA_FOUND THEN
NULL;
WHEN OTHERS THEN
RAISE;
END sp_AddPR;

Cheer up, Hughesie
create table tblpr(id          number(10)   not null
                  ,prtype      varchar2(10) not null
                  ,prteamid    varchar2(10) not null
                  ,pryear      number(4)    not null
                  ,prmonth     varchar2(12) not null
                  ,pralertdate date         not null
                  ,constraint tblpr_pk primary key (id));
/* Not sure about the natural key, but use this to tell "if record exists" */
create unique index tblrpr_ux1 on tblpr(prtype, prteamid);             
create sequence tblpr_id_seq;
create or replace package tblpr_te
as
   subtype tblpr_rt is tblpr%rowtype;  
   subtype prtype_t is tblpr.prtype%type;
   subtype prteamid_t is tblpr.prteamid%type;
   subtype pryear_t is tblpr.pryear%type;
   subtype prmonth_t is tblpr.prmonth%type;
   subtype pralertdate_t is tblpr.pralertdate%type;
   procedure add(po_exists out pls_integer
                ,pi_prtype in  prtype_t 
                ,pi_team   in  prteamid_t
                ,pi_year   in  pryear_t
                ,pi_month  in  prmonth_t
                ,pi_alert  in  pralertdate_t);
end tblpr_te;
create or replace package body tblpr_te
as
   procedure add(po_exists out pls_integer
                ,pi_prtype in  prtype_t 
                ,pi_team   in  prteamid_t
                ,pi_year   in  pryear_t
                ,pi_month  in  prmonth_t
                ,pi_alert  in  pralertdate_t)
   is
   begin
      insert into tblpr(id
                       ,prtype
                       ,prteamid
                       ,pryear
                       ,prmonth
                       ,pralertdate)
               values (tblpr_id_seq.nextval
                      ,pi_prtype
                      ,pi_team
                      ,pi_year
                      ,pi_month
                      ,pi_alert);
      po_exists := 0;
   exception
   when dup_val_on_index
   then
      po_exists := 1;
   end add;   
end tblpr_te;
select * from tblpr;
set serveroutput on
declare
  l_exists pls_integer;
begin
   tblpr_te.add(l_exists, 'A_Type', 'Some_Team', 2008, 'January', sysdate +12);
   commit;  
   dbms_output.put_line('l_exists: ' || l_exists);
end;
select * from tblpr;
drop package tblpr_te;
drop sequence tblpr_id_seq;
drop table tblpr purge
/Regards
Peter

Similar Messages

  • Data Service Not showing all the out param values in Oracle Store proc call

    Hi,
    I have imported a Oracle stored proc which takes 3 input params and gives 33 out params.
    While testing the Data Service , it is showing only the First 3 out params.
    I tried the same request thrught JDBC code and it is showing results for some of the other params.
    Is this any DSP issue ?
    Thanks
    Gkumar

    Open a case with Customer Support and ask for the patch on CR295750.

  • Function with OUT params

    Hi All,
    I have pondered over this for long but coudnt find a way myself..How do I declare and use an OUT param in an Oracle function,considering it can return only one value at a time. I would appreciate if you can give an example and explain.
    Thanks.

    SQL>  create or replace function f1(p1 in number,p2 out varchar2)
      2   return number is
      3   begin
      4    p2 := 'i am returning '||p1*2;
      5    return p1*2;
      6   end;
      7  /
    SQL> declare
      2   n number;
      3   v varchar2(20);
      4  begin
      5   n := f1(5,v);
      6   dbms_output.put_line(v);
      7   dbms_output.put_line(n);
      8  end;
      9  /
    i am returning 10
    10
    PL/SQL procedure successfully completed.
    Message was edited by:
            jeneesh
    Better you post the specific problem..                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Calling Oracle stored procedure with out param of user define type from Entity Framework 5 with code first

    Guys i am using Entity Framework 5 code first (I am not using edmx) with Oracle and all works good, Now i am trying to get data from stored procedure which is under package but stored procedure have out param which is user define type, Now my question is
    how i will call stored procedure from entity framework
    Thanks in advance.

    I agree with you, but issue is we have lots of existing store procedure, which we need to call where damn required. I am sure those will be few but still i need to find out.
    If you think you are going to get existing MS Stored Procedures  or Oracle Packages that had nothing to do with the ORM previously to work that are not geared to do simple CRUD operations with the ORM and the database tables, you have a rude awakening
    coming that's for sure. You had better look into using ADO.NET and Oracle Command objects and call those Oracle Packages by those means and use a datareader.
    You could use the EF backdoor, call Oracle Command object and use the Packages,  if that's even possible, just like you can use MS SQL Server Stored Procedures or in-line T-SQL via the EF backdoor.
    That's about your best shot.
    http://blogs.msdn.com/b/alexj/archive/2009/11/07/tip-41-how-to-execute-t-sql-directly-against-the-database.aspx

  • How to get two out param which is used in Procedure

    hi experts,
    Am keep on thinking, but not yet answer myself.. so am here
    Using Jdev11.1.1.5.0-adfbc.
    I had in db, procedure like this
    PROCEDURE proc_find_x_cal_year_period
         p_bu                    VARCHAR2,
         p_date                    DATE,
         p_year           OUT          NUMBER,
         p_period             OUT           NUMBER
    ).................i wrote like this in My AM, Procedure is execution and printing out param values Perfect
        public void ProcFindxCalYearPeriod(String pbu,
                                        oracle.jbo.domain.Date pdate)
                CallableStatement st = null;
                try{
                String sql = "begin proc_find_x_cal_year_period" +
                    "(:pbu," +
                    ":pdate," +
                    ":pyear," +
                    ":pperiod)" +
                    ";" +
                    "end;";
                st=getDBTransaction().createCallableStatement(sql,this.getDBTransaction().DEFAULT);
                st.setObject("p_bu",pbu);
                st.setObject("pdate",pdate);
                st.registerOutParameter("pyear",Types.VARCHAR);
                st.registerOutParameter("pperiod",Types.VARCHAR);
                st.execute();
                System.out.println("pyear" +(String)st.getObject("pyear"));
                System.out.println("pperiod" +(String)st.getObject("pperiod"));
                catch(SQLException e)
                throw new JboException(e);
                finally
                if(st!=null)
                try{
                st.close();
                catch(SQLException e){}
                }what i did/my need:
    i paste this ProcFindxCalYearPeriod in my one of the Eo and while am validating one of the field,this procedure should call at the time of calling, two out parameters set into two of the corresponding setter methods.
    (String)st.getObject("pyear")
    (String)st.getObject("pperiod")value is here i want to set into setAttributeInternal("x",(String)st.getObject("pyear") );
    setAttributeInternal("x1",(String)st.getObject("pperiod") );
    i hope you all understood.

    In your procedure you should create an object to hold the outputs and return this object
    public ProcResult ProcFindxCalYearPeriod(String pbu, oracle.jbo.domain.Date pdate)
                CallableStatement st = null;
                try{
                String sql = "begin proc_find_x_cal_year_period" +
                    "(:pbu," +
                    ":pdate," +
                    ":pyear," +
                    ":pperiod)" +
                    ";" +
                    "end;";
                st=getDBTransaction().createCallableStatement(sql,this.getDBTransaction().DEFAULT);
                st.setObject("p_bu",pbu);
                st.setObject("pdate",pdate);
                st.registerOutParameter("pyear",Types.VARCHAR);
                st.registerOutParameter("pperiod",Types.VARCHAR);
                st.execute();
                System.out.println("pyear" +(String)st.getObject("pyear"));
                System.out.println("pperiod" +(String)st.getObject("pperiod"));
                //assuming that you are getting the desired outputs
                *ProcResult outputs=new ProcResult();*
                *outputs.setOutParam1((String)st.getObject("pyear"));*
                *outputs.setOutParam2((String)st.getObject("pperiod"));*
                *return outputs;*
                catch(SQLException e)
                throw new JboException(e);
                finally
                if(st!=null)
                try{
                st.close();
                catch(SQLException e){}
                }Now you call this procedure like this
    ProcResult execProc= ProcFindxCalYearPeriod(paramValue1, paramValue2);
    //you can get the proc outputs by calling
    String firstOutput = execProc.getOutParam1();
    String second = execProc.getOutParam2();But the question is why you are calling setAttributeInternal() while you are validating an attribute?
    I think this is not correct.

  • Arrays as out param on stored procedure causes hang

    Hi,
    I would like to be able to use an ARRAY to pass data back from a java stored procedure. Calling the stored procedure using jdbc, the procedure hangs. If I change the out param to a VARCHAR, the procedure works fine (although, of course, the size of the data returned is limited).
    I defined a varray type:
    CREATE TYPE str_array AS VARRAY(100) OF VARCHAR2(255);
    I defined the stored procedure:
    CREATE OR REPLACE PROCEDURE ob_snapshot(symbol VARCHAR2, start_time DATE, end_time DATE, interval NUMBER, depth NUMBER, output_result IN OUT STR_ARRAY)
    AS LANGUAGE JAVA
    NAME 'OBSnapshot.snapshot(java.lang.String, java.sql.Timestamp, java.sql.Timestamp, int, int, oracle.sql.ARRAY[])';
    The execute on the CallableStatement never finshes. Any ideas ?
    Thanks for the help,
    Chris Opler
    null

    I recommend you declare your iterator as follows :
    public class yourApp {
    #sql public static iterator Temp1 (...);
    null

  • Getting a ref cursor out of a procedure

    Hello,
    I am having some issues getting the ref cursor out of this procedure that returns a ref cursor when given inputs.
    I have included the code below and made bold the call to the package and procedure where the requested function lies. I put c2 in the first parameter because that is the out and is defined first in the procedure. Am I going about this the wrong way? I am mainly a .NET developer and am still learning the syntax of PL/SQL.
    Thanks!
    Jeffrey Kevin Pry
    DECLARE
    TYPE r_cursor IS REF CURSOR;
    c2 r_cursor;
    CURSOR c1
    IS
    SELECT *
    FROM ELEMENT E
    WHERE E.SUBTYPE_CD = 'PAT';
    BEGIN
    FOR ROW_ITEM IN c1
    LOOP
    PKG_DTEST.GET_CHILDREN(c2,ROW_ITEM.ELEMENT_ID,1);
    FOR ROW_ITEM2 in c2
    LOOP
    dbms_output.put_line(ROW_ITEM2.ELEMENT_ID);
    END LOOP;
    END LOOP;
    END;
    Edited by: jeffrey.pry on Jan 21, 2011 6:01 AM

    You should probably post the code of PKG_DTEST.GET_CHILDREN as well as the error you are getting. It's hard to troubleshoot without knowing all the parts and pieces.
    Additionally, I see that you are using a nested FOR loop to process your data. You should rethink this. The best way to process data in Oracle is to compact it all into a single SQL statement if possible. If you are having trouble doing this please post the following and we can help.
    1. Oracle version (SELECT * FROM V$VERSION)
    2. Sample data in the form of CREATE / INSERT statements.
    3. Expected output
    4. Explanation of expected output (A.K.A. "business logic")
    5. Use \ tags for #2 and #3. See FAQ (Link on top right side) for details.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • ADLSP stops sending REFCURSOR out params when one of the out params is null

    Hi All,
    I have a package that returns some params. One of the params is a REFCURSOR (Oracle). If an out param before it contains null, the refcursor is not shown in the ALDSP XML response.
    Any ideas if this is a bug?
    Thanks,
    Daniel

    If you have the same problem, then you need the same solution.
    Open a case with Customer Support and ask for the patch on CR295750.

  • How do I find out the version of  Oracle Time Zone files?

    Hello there,
    How do I find out the version of Oracle Time Zone files? I'm in the process of applying the recent oracle patch and need to find out the version of oracle time zone in my db. Could you please help me?

    run
    SELECT version FROM v$timezone_file;

  • How can I find out the java version Oracle has ?

    How can I find out the java version Oracle has built in?
    I've tried with ..
    SELECT comp_id, comp_name, version
    FROM dba_registry ;
    But I get.."table doesn't not exist".
    Thenks in advance!

    Pl post details of OS and database versions. Pl see this MOS Doc
    What Version of Java is Compatible With The Database JVM? [ID 438294.1]     
    and these Oracle docs
    11gR2 - http://docs.oracle.com/cd/E11882_01/appdev.112/e25518/adfns_environments.htm#ADFNS654
    11gR1 - http://docs.oracle.com/cd/B28359_01/java.111/b31225/whatsnew.htm
    HTH
    Srini

  • Find out decimal value in oracle

    Hi,
    how to find out decimal value in oracle
    eg, select find_decimal(10.55) from dual --> should give .55
    20.432 --> .432
    pls help

    Like this?
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (select 10.55 as dec_num from dual)
      2  --
      3  select dec_num - trunc(dec_num) as dec_part
      4* from t
    SQL> /
      DEC_PART
           .55
    SQL>

  • Returning the control out of the procedure

    Gurus,
    Please see my code
    BEGIN
         BEGIN                                    -- To check whether the user(Record) exists in the table
                SELECT a.code, a.code_desc                                     
              INTO L_code, L_code_desc
                FROM CODE_DETAIL a, USER_ROLE_PRIVS b
                WHERE a.code_desc = b.granted_role
                AND a.code_type like '%CATR%'
                AND b.username = I_U_ID;
         EXCEPTION
              WHEN NO_DATA_FOUND THEN
              O_ERR_MSG := 'N';
         END;
      IF L_CODE <> '1' AND L_CODE <> '2' AND L_CODE <> '3' THEN     -- To check whether there is any other role associated other than 1, 2 or 3
         O_ERR_MSG := 'Y';
      END IF;This is a piece of code which is a part of procedure .. Now whenever I have O_ERR_MSG initialized to Y or N .. it should come out of the procedure... What's happenning now is, variable is getting initialized and executing the rest of the code, which shouldnt happen ..
    Can you please tell me how to pass the control back to the procedure without executing the other lines ?
    Regards

    Ok... posting the entire code
    CREATE OR REPLACE PROCEDURE AFE_CHECK_SUBMIT (I_u_id in varchar2, I_ord_num in number, O_rol out VARCHAR2, O_app_check OUT Varchar2, O_v_app_check out number, O_v_otb_check out number, O_AMT OUT NUMBER, O_ERR_MSG OUT VARCHAR2, O_error_message IN OUT varchar2 ) IS
    L_role                  varchar2(30); 
    L_approval_limit        number;         L_otb_limit             number;                
    L_approval_level        varchar2(5);           
    L_tolerance_limit       varchar2(40);            L_program VARCHAR2(60)  := 'AFE_CHECK_SUBMIT';
    L_code                  VARCHAR2(10);
    L_code_desc             VARCHAR2(30);
    L_app_check             NUMBER;
    L_otb_check             NUMBER;
    L_amt                   NUMBER;
    L_otb_amt1              NUMBER;
    L_order_no           NUMBER;
    L_status           VARCHAR2(1);
    CURSOR C_PO_AMT IS SELECT i.dept, i.class, h.order_type, to_CHAR(h.otb_eow_date, 'MONYYYY') po_month, sum(o.qty_ordered * o.unit_cost) po_amt
    FROM ITEM_MASTER i, ORDLOC o, ORDHEAD h
    WHERE i.item = o.item
    AND o.order_no = h.order_no
    AND o.order_no = I_ord_num
    GROUP BY i.dept, i.class, h.order_type, to_CHAR(h.otb_eow_date, 'MONYYYY');
    CURSOR C_OTB_CALCULATE(order_type VARCHAR2, order_eow_date date, dep number, clas number ) IS
    SELECT sum(decode(order_type, 'ARB', a_budget_amt-a_approved_amt,
                                             'BRB', b_budget_amt-b_approved_amt,
                                             'N/B', n_budget_amt-n_approved_amt,
                                                 0)) otb_amt1
      FROM OTB
      WHERE to_char(EOW_DATE,'MONYYYY') = to_char(order_eow_date,'MONYYYY')
      AND DEPT = dep
      AND CLASS = clas
          GROUP BY to_CHAR(ORDER_EOW_DATE,'MONYYYY'),DEPT,CLASS;
          C2 C_OTB_CALCULATE%rowtype;
          c3 C_PO_AMT%rowtype;
    CURSOR C_ROLE_CHECK IS
      SELECT a.code, a.code_desc                                      -- checking the role of the user who has logged in
      FROM CODE_DETAIL a, USER_ROLE_PRIVS b
      WHERE a.code_desc = b.granted_role
      AND a.code_type like '%CATR%'
      AND b.username = I_U_ID;
      L_ROLE_CHECK C_ROLE_CHECK%ROWTYPE;
    BEGIN
       dbms_output.put_line('User id is :' || I_u_id);
       dbms_output.put_line('Selecting the role');
       BEGIN     
         OPEN C_ROLE_CHECK;
         LOOP
              FETCH C_ROLE_CHECK INTO L_ROLE_CHECK;
              EXIT WHEN C_ROLE_CHECK%NOTFOUND;
              L_code := L_ROLE_CHECK.code;
         END LOOP;
       EXCEPTION
              WHEN NO_DATA_FOUND THEN
                 dbms_output.put_line('No Record in table');
              O_ERR_MSG := 'N';  
    END;
      dbms_output.put_line('Role is :' || L_code);
      IF L_CODE <> '1' OR L_CODE <> '2' OR L_CODE <> '3' THEN
         O_ERR_MSG := 'Y';
         dbms_output.put_line('Unidentified user');
      END IF;
      IF L_code = '1' THEN                                       -- If user id is planner
           O_rol := '1';
         dbms_output.put_line('User is PLANNER (ROLE 1)');
            SELECT r.ORD_APPR_AMT                                   -- will be checking the approval limit of that role
            INTO L_approval_limit          
            FROM  RTK_ROLE_PRIVS r, CODE_DETAIL c
            WHERE r.ROLE = c.CODE_DESC
            AND c.CODE = L_code;
         dbms_output.put_line('Approval limit is :' || L_approval_limit);
            OPEN C_PO_AMT;                                          -- OTB check based on dept,class
            LOOP
              FETCH C_PO_AMT into c3;
                    EXIT when c_PO_AMT%notfound;
              dbms_output.put_line('Entered 1st loop');
                    OPEN C_OTB_CALCULATE(c3.order_type, TO_DATE(c3.po_month,'MONYYYY'), c3.dept, c3.class);
                    LOOP
                   dbms_output.put_line('Entered 2nd loop');
                         FETCH C_OTB_CALCULATE into c2;
                            EXIT WHEN C_OTB_CALCULATE%notfound;
                            L_amt := c3.PO_AMT;
                   dbms_output.put_line('PO AMT IS:' || L_amt);
                   IF c3.PO_AMT > L_approval_limit THEN    -- Checking whether amount greater than approval lim
                        dbms_output.put_line('Approval limit exceeded');
                                 L_app_check := 1;
                                    O_app_check := 'T';
                                    O_v_app_check := 1;
                        O_amt := L_amt;
                        dbms_output.put_line('Approval check is:' || L_app_check);
                        dbms_output.put_line('Approval check exceeded? :' || O_app_check);
                        dbms_output.put_line('Parameter for Approval check is:' || O_v_app_check);
                            ELSIF C3.PO_AMT <= L_approval_limit then
                        dbms_output.put_line('Approval limit not exceeded');
                        dbms_output.put_line('Approval check is:' || L_app_check);
                        dbms_output.put_line('Parameter for Approval check is:' || O_v_app_check);
                                    L_app_check := 0;
                                    O_v_app_check := 0;
                            END IF;
                   IF c3.PO_AMT > c2.OTB_AMT1 THEN         -- Checking whether amount greater than OTB amount
                        dbms_output.put_line('OTB AMT is :' || c2.otb_amt1);
                        dbms_output.put_line('OTB limit Exceeded');
                                 L_otb_check := 1;
                                    O_app_check := 'T';
                                    O_v_otb_check := 1;
                        O_amt := L_amt;
                        dbms_output.put_line('OTB check is:' || L_otb_check);
                        dbms_output.put_line('OTB check exceeded? :' || O_app_check);
                        dbms_output.put_line('Parameter for OTB check is:' || O_v_otb_check);
                            ELSIF C3.PO_AMT <= C2.OTB_AMT1 THEN
                        dbms_output.put_line('OTB limit not exceeded');
                                    L_otb_check := 0;
                                    O_v_otb_check := 0;
                        dbms_output.put_line('OTB check is:' || L_otb_check);
                        dbms_output.put_line('Parameter for OTB check is:' || O_v_otb_check);
                            END IF;
                    END LOOP;
                    CLOSE C_OTB_CALCULATE;
            END LOOP;
            CLOSE c_PO_AMT;
         IF L_app_check = 0 and L_otb_check = 0 then            
              SELECT ORDER_NO, STATUS                     -- Checking whether there is a duplicate order number
              INTO L_order_no, L_status                    
              FROM AFE_POAPPROVAL
              WHERE ORDER_NO = I_ord_num;
              IF L_status = 'O' then                         -- If found and its stauts is open, update the record by changing the status column to "C"
                   UPDATE AFE_POAPPROVAL
                   SET STATUS = 'C'
                   WHERE ORDER_NO = I_ord_num;
                   COMMIT;
              END IF;
              INSERT INTO AFE_POAPPROVAL                    -- Inserting the record into AFE_POAPPROVAL when OTB and approval limit is below the PO amt
                    VALUES (I_ord_num, 1,'O',I_u_id,'ROLE1','N','N', SYSDATE,'S', L_amt);
              dbms_output.put_line('Inserted Record into AFE_POAPPROVAL');
                    COMMIT;                
            END IF;
          ELSIF L_code = '2' THEN                            -- If user id is category manager
         dbms_output.put_line('User is Category manager (ROLE 2)');          
               O_rol := '2';
                  SELECT r.ORD_APPR_AMT                                        -- will be checking the approval limit of that role
                  INTO L_approval_limit          
                  FROM  RTK_ROLE_PRIVS r, CODE_DETAIL c
                  WHERE r.role = c.CODE_DESC
                  AND c.CODE = L_code;
               dbms_output.put_line('Approval limit is :' || L_approval_limit);
                  OPEN c_PO_AMT;                                          -- OTB check based on dept,class
                  LOOP
                       FETCH c_PO_AMT into c3;
                    EXIT when c_PO_AMT%notfound;
              dbms_output.put_line('Entered 1st loop');
                    OPEN C_otb_CALCULATE(c3.order_type, TO_DATE(c3.po_month,'MONYYYY'), c3.dept, c3.class);
                    LOOP
                         FETCH C_OTB_CALCULATE into c2;
                            EXIT WHEN C_OTB_CALCULATE%notfound;
                   dbms_output.put_line('Entered 2nd loop');
                            L_amt := c3.PO_AMT;
                   dbms_output.put_line('PO AMT is:' || L_amt);
                            IF c3.PO_AMT > L_approval_limit THEN    -- Checking whether amount greater than approval limit
                        dbms_output.put_line('Approval limit exceeded');
                                 L_app_check := 1;
                                    O_app_check := 'T';
                                    O_v_app_check := 1;
                        O_amt := L_amt;
                        dbms_output.put_line('Approval check is:' || L_app_check);
                        dbms_output.put_line('Approval check exceeded? :' || O_app_check);
                        dbms_output.put_line('Parameter for Approval check is:' || O_v_app_check);
                            ELSE
                        dbms_output.put_line('Approval limit not exceeded');
                                    L_app_check := 0;
                                    O_v_app_check := 0;
                        dbms_output.put_line('Approval check is:' || L_app_check);
                        dbms_output.put_line('Parameter for Approval check is:' || O_v_app_check);
                            END IF;
                            L_otb_amt1 := c2.OTB_AMT1;
                   dbms_output.put_line('Selecting tolerance limit');
                            SELECT cd.code_desc                                     -- will be chekcing the tolerance limit
                            INTO L_tolerance_limit
                            FROM CODE_DETAIL cd, CODE_HEAD ch
                            WHERE ch.CODE_TYPE = cd.code_type
                            AND ch.CODE_TYPE = 'OTBT';
                            L_tolerance_limit := to_number(L_tolerance_limit);
                   dbms_output.put_line('Tolerance limit is:' || L_tolerance_limit);
                            L_otb_limit := c2.OTB_AMT1-(c2.OTB_AMT1 * (1- (L_tolerance_limit/100))); -- Will be calculating the tolerance limit
                   dbms_output.put_line('OTB AMT is :' || L_otb_amt);
                            IF c3.PO_AMT > L_otb_limit THEN         -- Checking whether amount greater than OTB amount
                        dbms_output.put_line('OTB limit exceeded');
                                 L_otb_check := 1;
                                    O_app_check := 'T';
                                    O_v_otb_check := 1;
                        O_amt := L_amt;
                        dbms_output.put_line('OTB check is:' || L_otb_check);
                        dbms_output.put_line('OTB check exceeded? :' || O_app_check);
                        dbms_output.put_line('Parameter for OTB check is:' || O_v_otb_check);
                            ELSE
                        dbms_out.put_line('OTB Limit not exceeded');
                                    L_otb_check := 0;
                                    O_v_otb_check := 0;
                        dbms_output.put_line('OTB check is:' || L_otb_check);
                        dbms_output.put_line('Parameter for OTB check is:' || O_v_otb_check);
                            END IF;
                    END LOOP;
                    CLOSE C_OTB_CALCULATE;
                  END LOOP;
                  CLOSE c_PO_AMT;
                  IF L_app_check = 0 and L_otb_check = 0 THEN            
                    SELECT ORDER_NO, STATUS                     -- Checking whether there is a duplicate order number
              INTO L_order_no, L_status
              FROM AFE_POAPPROVAL
              WHERE ORDER_NO = I_ord_num;
              IF L_status = 'O' then                         -- If found and its stauts is open, update the record by changing the status column to C
                   UPDATE AFE_POAPPROVAL
                   SET STATUS = 'C'
                   WHERE ORDER_NO = I_ord_num;
                   COMMIT;
              END IF;
                    INSERT INTO AFE_POAPPROVAL                    -- Inserting the record into AFE_POAPPROVAL when OTB and approval limit is below the PO amt
                    VALUES (I_ord_num, 1,'O',I_u_id,'ROLE2','N','N', SYSDATE, 'S', L_amt);                 
                    COMMIT;
              dbms_output.put_line('Inserted Record into AFE_POAPPROVAL');
                  END IF;
           ELSIF L_code = '3' THEN                                         -- If user id is category head
         dbms_output.put_line('User is Category Head (ROLE3)');
                O_rol := 3;
            OPEN c_PO_AMT;                                          -- OTB check based on dept,class
            LOOP
                 FETCH c_PO_AMT into c3;
                    EXIT when c_PO_AMT%notfound;
              dbms_output.put_line('Entered 1st loop');
                    OPEN C_OTB_CALCULATE(c3.order_type, to_date(c3.po_month,'MONYYYY'), c3.dept, c3.class);
                    LOOP
                         FETCH C_OTB_CALCULATE into c2;
                            EXIT WHEN C_OTB_CALCULATE%notfound;
                   dbms_output.put_line('Entered 2nd loop');     
                            L_amt := c3.PO_AMT;
                   dbms_output.put_line('PO AMT is :' || L_amt);     
                            IF c3.PO_AMT > c2.OTB_AMT1 THEN         -- Checking whether amount greater than OTB amount
                        dbms_output.put_line('OTB AMT is :' || c2.otb_amt1);
                        dbms_output.put_line('OTB Limit exceeded');
                                 L_otb_check := 1;
                                    O_app_check := 'T';
                                    O_v_otb_check := 1;                                        
                        O_amt := L_amt;
                        dbms_output.put_line('OTB check is:' || L_otb_check);
                        dbms_output.put_line('OTB check exceeded? :' || O_otb_check);
                        dbms_output.put_line('Parameter for OTB check is:' || O_v_otb_check);
                            ELSE
                        dbms_output.put_line('OTB limit not exceeded');
                                    L_otb_check := 0;
                                    O_v_otb_check := 0;
                        dbms_output.put_line('OTB check is:' || L_otb_check);
                        dbms_output.put_line('Parameter for OTB check is:' || O_v_otb_check);
                            END IF;
                    END LOOP;
                    CLOSE C_OTB_CALCULATE;
            END LOOP;
            CLOSE c_PO_AMT;
            IF L_otb_check = 0 THEN                                
    IF L_otb_check = 0 THEN                                
              OPEN C_RECORD_CHECK;
              LOOP
                   FETCH C_RECORD_CHECK INTO L_RECORD_CHECK;
                   EXIT WHEN C_RECORD_CHECK%notfound;
                   IF C_RECORD_CHECK%FOUND THEN
                        UPDATE AFE_POAPPROVAL
                        SET STATUS = 'C'
                        WHERE ORDER_NO = I_ord_num;
                        COMMIT;
                   END IF;
              END LOOP;
              INSERT INTO AFE_POAPPROVAL                    -- Inserting the record into AFE_POAPPROVAL when otb and approval limit is below the po amount
                     VALUES (I_ord_num, 1,'O',I_u_id,'ROLE3','Y','N', SYSDATE,'S', L_amt);
                     COMMIT;
              dbms_output.put_line('Inserted Record into AFE_POAPPROVAL');
            END IF;
         END IF;
      EXCEPTION
         WHEN OTHERS THEN
            O_error_message := SQL_LIB.CREATE_MSG('PACKAGE_ERROR',
                                                   SQLERRM,
                                                   L_program,
                                                   TO_CHAR(SQLCODE));
      END AFE_CHECK_SUBMIT;
    /Now i am executing the procedure ...
    SQL>SQL> @OUT_SUBMIT;
    Enter value for user: RMS12DEV
    old 12: o_user :='&user';
    new 12: o_user :='RMS12DEV';
    Enter value for order: 6139
    old 13: o_order :=&order;
    new 13: o_order :=6139;
    User id is :RMS12DEV
    Selecting the role
    No Record in table
    Role is :
    o_rol:
    O_app_check:
    O_v_app_check:
    O_v_otb_check:
    O_amt:
    O_ERR_MSG: N
    O_error_message:
    PL/SQL procedure successfully completed.
    If you have looked at the output .. after the variable is intialized to 'N', still I am getting msgs displayed .. Hope this is clear .. Now can you suggest the solution...
    Regards
    Message was edited by:
    Seshu
    Message was edited by:
    Seshu

  • Send out Email from Procedure

    Within a PL/SQL stored procedure, if an execution error occurrs, I want to receive a corresponding email to notify me as such. How can I do it?
    procedure p_exe_error(
    begin
    //If there is an error, send email to [email protected] to notify the error (error_message =xxxxxxxxxx)
    What should I do here?
    end;
    Thanks
    Scott

    This appears to be a duplicate
    Send out Email from Procedure
    Justin

  • How to find out difference between IAS Oracle Home patches and 10.1.2 Oracl

    How to find out difference between IAS Oracle Home patches and 10.1.2 Oracle Home patches.
    I have read me document but i could not able to understand.
    Please help me

    user10721329 wrote:
    How to find out difference between IAS Oracle Home patches and 10.1.2 Oracle Home patches.
    I have read me document but i could not able to understand.
    Please help meWhat docoument you are referring to?
    If you source the application env file APPS<CONTEXT_NAME>.env file under $APPL_TOP directory then this will set ORACLE_HOME to 10.1.2
    If you source the application env file <CONTEXT_NAME>.env file under $INST_TOP/ora/10.1.3 directory then this will set ORACLE_HOME to 10.1.3
    Environment Settings
    http://docs.oracle.com/cd/E18727_01/doc.121/e12841/T120505T120509.htm#F_92659x3Ax20H1x20Head1x3Ax20Environmentx20Settings
    Thanks,
    Hussein

  • How to execute the packaged procedure(having out param) in TOAD for Oracle

    Hi.
    Could you help me
    How to execute the packaged procedure having out parameters in TOAD for Oralce..
    Thanks..

    Use anonymous PL/SQL block to execute it.
    Example.
    DECLARE
      <out variable name> <out variable data type>;
    BEGIN
      <package name>.<procedure name>(<out variable name>);
    END;

Maybe you are looking for

  • From Leopard back to Tiger

    Odd question to ask I know but have experienced some problems since upgrading to Leopard, one being that my Superdrive no longer burns DVD's!! This appears to be an ongoing thing judging by some threads I've seen and I can't really afford to be going

  • Unable to find abstract layer object definition

    Hi, I am using SoapUI 3.6.1. When I send a request "getAttribute" along with all the optional parameters, specifying the Username and password in the Request Properties window, I am getting following error. <ns1:VdxServiceException xmlns="http://www.

  • Code snippet -- "Send to Back"?

    Hello, I've modified the code snippet "Bring Object to the Front" to bring a given stage symbol to the front on mouse over. My question is, what code do I add to make the symbol go to the back on mouse out? My code is below -- exact same as the code

  • Sending Large size files through JMS adapter.

    We want to receive files larger than 5MB via the JMS receiver adapter. The receiver side has WebSphere MQSeries version 5.3.12. The channel we are using is SYSTEM.AUTO.SVRCONN. I can see a MQJMS2007 error in RWB for the JMS adapter. Does the XI JMS a

  • Sound no external speakers

    Just got a MacPro but I can't get the external sound to work. Plugged in audio out,they are self powered made by Boston. Yes I checked output in system preferences. Any help?