Stored proc execution status, pls help

hi,
i need to know if there is a way to find out whether an sp has been executed successfully or not, with the status code being returned.
i know about the dbms_output.getline() function but i don't know how to use it!
pls help
thank you

Hi,
do you mean something like that ?
SQL> create or replace procedure getData(id in number)
  2  is
  3   status number;
  4  begin
  5   select count(1) into status from emp where empno = id;
  6   if status > 0 then
  7     dbms_output.put_line('Success');
  8   else
  9     dbms_output.put_line('Failed');
10   end if;
11  end;
12  /
&nbsp
Procedure created.
&nbsp
SQL> set serveroutput on
SQL> exec getData(1)
Failed
&nbsp
PL/SQL procedure successfully completed.
&nbsp
SQL> exec getData(7369)
Success
&nbsp
PL/SQL procedure successfully completed.
&nbspRgds.

Similar Messages

  • Stored subprogram execution status

    Hi Friends,
    I need a information regarding PL/SQL stored procedure and function.
    My query is whenever i am executing a pl/sql procedure or function,how can i get the execution status of that stored procedure or function..that means whether it is already executed or still running.
    Is there any data dictionary views provided by oracle or any supplied packages to track this.
    Pls help me.....
    Thanx and Regadrs
    somy

    um.. what i am telling you is the similar thing whats been done in my application,
    create or replace procedure p_test is
    being
    --make one table execution_state
    --make an entry for procedure p_test = 'BUSY'
    -- this should be done at very start when procedure is executed
    --if procedure is successfully completed make the state p_test = 'IDLE'
    exception
    --if there is an exception make state p_test = 'ERROR'
    end;
    now if you want to check where this procedure
    is running just query the table execution_state
    for entry p_test if the state is BUSY
    i.e. procedure is running,
    if its IDLE its successfully completed
    like this you can trace it,Message was edited by:
    Nicloei W

  • Using Statement rather than CallableStatement for stored proc execution

    Cleary, if you need to extract output parameters from a stored procedure, then you must use a CallableStatement to execute it. However, if your stored procedure just returns a basic ResultSet, or performs a database update, is there any penalty to using a regular Statement to execute the stored procedure?
    For example -
    String sql = "exec testprocedure 'param1' 'param2'";
    Statement stmt = conn.createStatement();
    ResultSet rs = stmt.executeQuery( sql );
    vs.
    CallableStatement cs = conn.prepareCall( "{call testprocedure(?,?)}" );
    cs.setString( 1, "param1" );
    cs.setString( 2, "param2" );
    ResultSet rs = cs.executeQuery();
    Any thoughts?

    Any thoughts?You would have to look at the actual driver code for a sure answer.
    But for any real database (which a stored proc suggests) I doubt there would be any difference at all. It would resolve to the same call.

  • Compilation Error in stored Proc !! Please help

    Hi,
    This is my stored procedure , it is giving error at line 20 . The error description is : ERROR line 20, col 1, ending_line 20, ending_col 6, Found 'ELSEIF', CASE is expected
    CREATE OR REPLACE PROCEDURE proc_MDM_GetCountry_tst
    Exist IN INTEGER,
    Search IN VARCHAR2,
    Country_c OUT SYS_REFCURSOR
    AS
    BEGIN
    IF Exist IS NOT NULL AND Search IS NOT NULL THEN
    OPEN Country_c FOR SELECT
    MDM_CODE,MDM_MASTER_CODE,MDM_DESCRIPTION,
    MDM_USER,MDM_EXIST,MDM_STATUS,MDM_ACTION,DAT_INSERT_DATE,
    DAT_INSERTED_BY,DAT_MODIFY_DATE,DAT_MODIFIED_BY
    from MDM_COUNTRY_MASTER WHERE MDM_EXIST = Exist and MDM_STATUS='approved' AND MDM_DESCRIPTION LIKE '%'+Search+'%';
    ELSEIF Exist IS NULL AND Search IS NOT NULL THEN (Error line 21)
    OPEN Country_c FOR SELECT
    MDM_CODE,MDM_MASTER_CODE,MDM_DESCRIPTION,
    MDM_USER,MDM_EXIST,MDM_STATUS,MDM_ACTION,DAT_INSERT_DATE,
    DAT_INSERTED_BY,DAT_MODIFY_DATE,DAT_MODIFIED_BY
    from MDM_COUNTRY_MASTER WHERE MDM_STATUS='approved';
    ELSEIF Exist IS NOT NULL AND Search IS NULL THEN
    OPEN Country_c FOR SELECT
    MDM_CODE,MDM_MASTER_CODE,MDM_DESCRIPTION,
    MDM_USER,MDM_EXIST,MDM_STATUS,MDM_ACTION,DAT_INSERT_DATE,
    DAT_INSERTED_BY,DAT_MODIFY_DATE,DAT_MODIFIED_BY
    from MDM_COUNTRY_MASTER WHERE MDM_STATUS='approved' and MDM_EXIST = Exist;
    ELSE
    OPEN Country_c FOR SELECT
    MDM_CODE,MDM_MASTER_CODE,MDM_DESCRIPTION,
    MDM_USER,MDM_EXIST,MDM_STATUS,MDM_ACTION,DAT_INSERT_DATE,
    DAT_INSERTED_BY,DAT_MODIFY_DATE,DAT_MODIFIED_BY
    from MDM_COUNTRY_MASTER WHERE MDM_STATUS='approved' AND MDM_EXIST = 1;
    END IF;
    END proc_MDM_GetCountry_tst;
    Could any of you geeks please help me. I am new to oracle PL/SQL development. I used to work on SQL Server 2005 earlier.
    Thanks for your help.
    Edited by: user11342315 on Jul 2, 2009 10:00 PM

    ELSEIF should be ELSIF.
    See the documentation: http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/if_statement.htm#LNPLS01324
    Regards,
    Rob.

  • Stored Proc Execution through OS command using shell script

    Hi All,
    I have a requirement of executing one stored procedure before putting data in Table through JDBC adaptor and two stored procedures after that.
    I was thinking to write a shell script and execute it before and after message processing in adaptor.
    Can anybody please tell me how should i write a shell script for it?
    I have identified that exec <Stored_Proc_Name> is the syntax for it.
    Will i need to write something more in this script?
    Thanks,
    Atul

    Hi Atul,
    Stored procedures are written on the Database server for which you are going to write JDBC adapter.
    you will just call the storedprocedure in to your adapter.
    as per your requirement you shd run one stored procedure (let us say SP1) and then you have to push data into tables and then run SP2 and SP3...
    so for this write three stored procedures and call them into another SP. in this SP you call SP1 first then insert statement to insert data into tables and then SP2 and SP3.
    finally call SP into your JDBC adapter.
    you can call SP1 in SP as below
    Var_SQL :='call SP1 (''' || Var_1 || ''',''' || Var_2 ||''')' ;
    EXECUTE IMMEDIATE Var_SQL;
    i think for this shell script is not required.. correct me if i am wrong...
    Regards,
    Sukarna.

  • TECO status - pls help me to do a control

    Hi SAP gurus,
    I am seeking your assistance to help me..
    I want to control a tasklist to not allow changes in component whether adding or deletion BUT they are not working for deletion if user do a manual TECO.
    What i am doing in userexit?
    Program will read if material is deleted(manual delete) - have flag deletion.
    Then the program can capture the flag then prompt the error msg.
    BUT
    When user is doing manual TECO, flag of deletion is automatically assign.
    Then the program will capture the flag and prompt the error.
    How do i do to allow saving if user doing manual TECO??
    <u><b>My checking codes:</b></u>
    LOOP AT tafvgd_get WHERE phflg <> 'X'.
              CLEAR: stpo, ycam, plmz, ta_plmz, ta_stpo.
              SELECT SINGLE * FROM ycam WHERE plnnr = tafvgd_get-plnnr.
              IF sy-subrc = 0 AND ycam-ychgind NE 'Y'.
                SELECT * FROM plmz INTO CORRESPONDING FIELDS OF
                TABLE ta_plmz WHERE plnty = tafvgd_get-plnty
                              AND   plnnr = tafvgd_get-plnnr
                              AND   plnkn = tafvgd_get-plnkn
                              AND   loekz <> 'X'.
                SELECT * FROM stpo INTO CORRESPONDING FIELDS OF
                TABLE ta_stpo FOR ALL ENTRIES IN ta_plmz
                       WHERE stlty = ta_plmz-stlty
                       AND   stlnr = ta_plmz-stlnr
                       AND   stlkn = ta_plmz-stlkn
                       AND   lkenz <> 'X'.
    Not allowed additional material in campaign task list.
                LOOP AT resbd_get WHERE vornr = tafvgd_get-vornr
                                        AND xloek <> 'X'.
                  READ TABLE ta_stpo WITH KEY idnrk = resbd_get-matnr.
                  IF sy-subrc NE 0.
                    MESSAGE e778(yi).
                  ENDIF.
                ENDLOOP.
    Not allowed to delete material in campaign task list.
                LOOP AT ta_stpo.
                  READ TABLE resbd_get WITH KEY vornr = tafvgd_get-vornr
                                                matnr = ta_stpo-idnrk
                                                xloek = ''.
                  IF sy-subrc NE 0.
                    MESSAGE e777(yi) WITH ta_stpo-idnrk.
                  ENDIF.
                ENDLOOP.
              ENDIF.
            ENDLOOP.

    Hi Jagrut,
    Check FM EXTENDED_PROGRAM_CHECK and RS_SYNTAX_CHECK.
    Hope this helps.
    Thanks
    Lakshman

  • Multiple stored procs execution parallelly using single DBMS_SCHEDULER

    Hi All,
    I have to run 10 tasks - a few simultaneously, and a few periodically using DBMS_SCHEDULER.
    But instead of creating 10 different Schedulers, is there a way in Oracle to create a single scheduler and invoke the tasks base on respective times?
    I have been going thru SCHEDULERS documentation but i am unable to make much progress.
    Thanks,
    Chaitanya

    Hi,
    You can run the multiple process under the same scheduler to set the appropriate priority.
    DBMS_SCHEDULER.create_job (
    job_name => 'test_priority_job',
    job_type => 'PLSQL_BLOCK',
    job_action => 'BEGIN DBMS_LOCK.sleep(10); END;',
    start_date => SYSTIMESTAMP,
    repeat_interval => 'freq=minutely;',
    end_date => SYSTIMESTAMP + 1/48,
    enabled => FALSE,
    comments => 'Job used to test priorities.');
    DBMS_SCHEDULER.set_attribute (
    name => 'test_priority_job',
    attribute => 'job_priority',
    value => 1);
    DBMS_SCHEDULER.set_attribute (
    name => 'test_priority_job1',
    attribute => 'job_priority',
    value => 1);
    Like the above code.
    ~Kushal

  • Why execution status of stored procedure in shell script is returning same?

    Hi Friends,
    My shell script has below code to execute Pl/Sql procedure.depending on pl/sql procedure status i need to execute the script further.
    i am testing error condition.So i kept exe instead of exec for executing procedure.it suppose to return non zero.But iam not getting the correct status in shell script using $?.
    even for error condition also status is returning zero(0).How to catch execution status of stored procedure in shell script?
    can you please me suggest whats is wrong in below code?
    echo "*************************************************************"
    echo "             cleaning replica tables"
    echo "*************************************************************"
    sqlplus -s migrat/****@dotis01<<ENDOFSQL
    WHENEVER SQLERROR EXIT 1;
    exe PKG_OTU_HELPER.SP_CLEANUPREPLICA;
    Commit;
    exit;
    ENDOFSQL
    status=$?
    echo $status // showing 0 always.
    +if [ $status -ne 0 ]+
    then
    echo "issues in cleaning in replica tables"
    exit;
    fi
    +#Loading of data from flat files to migration tables using sqlldr programs+
    echo "*************************************************************"
    echo "      Loading of data from flat files to migration tables"
    echo "*************************************************************"
    sh /opt/finaclesoftware/UBS_10.4.02_AIX/AIX/DB/CRM/Oracle/OTU/Retail/ControlFiles/LoadData1.com
    Thanks,
    Venkat Vadlamudi

    The whenever sqlerror clause is a sqlplus command. When Oracle (that is, the sql engine of the pl/sql engine) raises and error in a sql statement, the whenever sqlerror command determines what happens.
    Exec is also a sqlplus command, exec <procedure> is shorthand for begin <procedure> end;, that is, it creates an anonymous block.
    Your misspelling of exec as exe is not an Oracle error, it is a sqlplus error. The command never actually gets to Oracle, so there has not been a sqlerror for whenever sqlerror to respons to.
    Consider, I do not have a procedure called p
    SQL> desc p
    ERROR:
    ORA-04043: object p does not existI try to call it with exe as in your code:
    SQL> exe p;
    SP2-0042: unknown command "exe p" - rest of line ignored.Note the error message is form sqlplus (SP2).
    But, if I call it correctly usinf exec:
    SQL> exec p;
    BEGIN p; END;
    ERROR at line 1:
    ORA-06550: line 1, column 7:
    PLS-00201: identifier 'P' must be declared
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignorednow I have a sql error, and whenever sqlerror exit 1 would quit sqlplus with a return value of 1.
    John

  • Help! about process chain execution status

    hi:
    we nearly have one problem about the process chain execution status,
    when error occured during  process chian execution, we fixed it in time,
    however, even the error repaired, its status still showed yellow, and this
    stop the subsequent process to excute.
    Any body who can provide some help to solve this problem? thanks in advance
    and looking forward to one reply.

    Hi ,
    Try this method
    Open the messages of a failed step by right clicking on it and selecting 'display messages'.
    In the opened popup click on the tab 'Chain'.
    In a parallel session goto transaction se16 for table rspcprocesslog and display the entries with the following selections:
    1. copy the variant from the popup to the variante of table rspcprocesslog
    2. copy the instance from the popup to the instance of table rspcprocesslog
    3. copy the start date from the popup to the batchdate of table rspcprocesslog
    Press F8 to display the entries of table rspcprocesslog.
    Now open another session and goto transaction se37. Enter RSPC_PROCESS_FINISH as the name of the function module and run the fm in test mode.
    Now copy the entries of table rspcprocesslog to the input parameters of the function module like
    described as follows:
    1. rspcprocesslog-log_id -> i_logid
    2. rspcprocesslog-type -> i_type
    3. rspcprocesslog-variante -> i_variant
    4. rspcprocesslog-instance -> i_instance
    5. enter 'G' for parameter i_state (sets the status to green).
    Now press F8 to run the fm.
    Now the actual process will be set to green and the following process in the chain will be started and the chain can run to the end.
    Regards,
    Ravi

  • Hey there, whenever i try to start iTunes in my laptop amsg coming up saying : data execution prevention prevented iTunes from starting (Dep), would you Pls help me out.I have windows vista installed.

    hey there, whenever i try to start iTunes in my laptop amsg coming up saying : data execution prevention prevented iTunes from starting (Dep), would you Pls help me out.I have windows vista installed.

    No, i do not have quickTime player.
    I have tried to close dep off for iTunes but failed to do so as i got a msg that iTunes can't work without Dep in execution data prevention.

  • Java stored proc status

    hello.
    What would trigger the change of "STATUS" from valid to invalid
    for a java stored procedure (status of the PROCEDURE, not the
    java class/source)?
    E.g.
    - loaded a java source/class
    - published it with CREATE PROCEDURE ...
    - the procedure inserts a row into some table X
    - select* from user_objects where object_type = 'PROCEDURE'; shows that
    the proc is valid
    - call the proc, fine
    - delete a column from the table X
    - select* from user_objects where object_type = 'PROCEDURE'; shows that
    the proc is still VALID
    - call the proc, the call actually completed without error! (but the new row didn't get inserted into the table)
    When the schema of a table that a java stored proc refers
    to changes, will the java stored proc automatically marked
    as "INVALID"? If not, when will this status changed from
    VALID to INVALID?
    Thanks.
    Min

    Min:
    A java stored procedure is marked as VALID or INVALID depending on whether Oracle had any problems loading the class file into the database. Since you had no problems loading the class file it will always be valid.
    Now, after you deleted the column in the table I would assume that the java stored procedure would have a problem when it tried to do an insert and it would throw an exception. Your java stored procedure is VALID, it just isn't executing properly and is more than likely throwing an exception.
    Sometimes an exception thrown from a jsp is written to a log file instead of to the console. I suspect that this is the case in your situation. You think that the call to the jsp executed with no errors, but I bet it didn't. You will probably find the errors somewhere in the oracle\ora90\admin\mydatabase directory. Look at the latest .trc file. (Note: the path I gave to the .trc files may be different depending on what version of oracle you are using).

  • Error w/ UPDATE in Stored Procedure - ORA-06553 PLS-306

    I get the following error when executing my stored proc. from a Perl script:
    DBI ERROR: ORA-06553: PLS-306: wrong number or types of arguments in call to 'UPDATE_USER_PROJMGR' (DBD ERROR: OCIStmtExecute),
    QUERY: DBI::st=HASH(0x238cd4)Now, it's passing the correct number of values, the UPDATE stmt stores them in the proper order and the procedure when created showed it was done so with no errors.
    What value could be out of whack with Oracle here? I don't get it. If anyone sees what I'm doing wrong here, please suggest it.
    Thanks!
    Here's my stored proc.
    CREATE OR REPLACE PROCEDURE UPDATE_USER_PROJMGR
    (dp_regleg IN DEFAULT_PROJECT_USER.REG_LEGAL%type,
    dp_netcred IN DEFAULT_PROJECT_USER.NETCRED_LOSS%type,
    dp_expreduc IN DEFAULT_PROJECT_USER.EXPENSE_REDUC_CKB%type,
    dp_stratgoal IN DEFAULT_PROJECT_USER.STRAT_GOALS%type,
    dp_audcompl IN DEFAULT_PROJECT_USER.AUDIT_COMPL%type,
    dp_revgen IN DEFAULT_PROJECT_USER.REV_GEN%type,
    dp_cacs IN DEFAULT_PROJECT_USER.CACS%type,
    dp_custit IN DEFAULT_PROJECT_USER.CUSTOMIT%type,
    dp_custimpact IN DEFAULT_PROJECT_USER.CUST_IMPACT%type,
    dp_callmgt IN DEFAULT_PROJECT_USER.CALL_MGT%type,
    dp_calltrk IN DEFAULT_PROJECT_USER.CALL_TRACK%type,
    dp_citilink IN DEFAULT_PROJECT_USER.CITILINK%type,
    dp_desktop IN DEFAULT_PROJECT_USER.DESKTOP%type,
    dp_dialer IN DEFAULT_PROJECT_USER.DIALER%type,
    dp_dri IN DEFAULT_PROJECT_USER.DRI%type,
    dp_engr IN DEFAULT_PROJECT_USER.ENGINEER%type,
    dp_img IN DEFAULT_PROJECT_USER.IMAGING%type,
    dp_ipdt IN DEFAULT_PROJECT_USER.IPDT%type,
    dp_mainfram IN DEFAULT_PROJECT_USER.MAINFR%type,
    dp_miscoth IN DEFAULT_PROJECT_USER.MISC_OTHER%type,
    dp_mortserv IN DEFAULT_PROJECT_USER.MORTSERV%type,
    dp_mortweb IN DEFAULT_PROJECT_USER.MORTWEB%type,
    dp_nonmortserv IN DEFAULT_PROJECT_USER.NON_MORTSERV%type,
    dp_origplat IN DEFAULT_PROJECT_USER.ORIG_PLAT%type,
    dp_qualmapping IN DEFAULT_PROJECT_USER.QUAL_MAP%type,
    dp_datawarehse IN DEFAULT_PROJECT_USER.DATAWARE_REPTS%type,
    dp_servappvend IN DEFAULT_PROJECT_USER.SERV_APP_VDR%type,
    dp_sbend IN DEFAULT_PROJECT_USER.SOUTHBEND%type,
    dp_websvcg IN DEFAULT_PROJECT_USER.WEB_SVCG%type,
    dp_projmgr IN DEFAULT_PROJECT_PROJMGR.PROJ_MGR%type,
    dp_status IN DEFAULT_PROJECT_PROJMGR.STATUS%type,
    dp_projtype IN DEFAULT_PROJECT_PROJMGR.IT_PROJ_TYPE%type,
    dp_projnum IN DEFAULT_PROJECT_PROJMGR.IT_PROJNUMBER%type,
    defprodid IN NUMBER)
    IS BEGIN
    -- UPDATE STATEMENT
    UPDATE DEFAULT_PROJECT_USER SET
    REG_LEGAL = dp_regleg, NETCRED_LOSS = dp_netcred,EXPENSE_REDUC_CKB = dp_expreduc, STRAT_GOALS = dp_stratgoal, AUDIT_COMPL = dp_audcompl,
    REV_GEN = dp_revgen,CACS = dp_cacs, CUSTOMIT = dp_custit, CUST_IMPACT = dp_custimpact,CALL_MGT = dp_callmgt,
    CALL_TRACK = dp_calltrk,CITILINK = dp_citilink,DESKTOP = dp_desktop,DIALER = dp_dialer,DRI = dp_dri,
    ENGINEER = dp_engr,IMAGING = dp_img,IPDT = dp_ipdt,MAINFR = dp_mainfram,MISC_OTHER = dp_miscoth,MORTSERV = dp_mortserv,
    MORTWEB = dp_mortweb,NON_MORTSERV = dp_nonmortserv,ORIG_PLAT = dp_origplat,QUAL_MAP = dp_qualmapping,DATAWARE_REPTS = dp_datawarehse,
    SERV_APP_VDR = dp_servappvend,SOUTHBEND = dp_sbend,WEB_SVCG = dp_websvcg
    WHERE DEFPROJ_ID = defprodid;
    UPDATE DEFAULT_PROJECT_PROJMGR SET
    PROJ_MGR = dp_projmgr,STATUS = dp_status,IT_PROJ_TYPE = dp_projtype,IT_PROJNUMBER = dp_projnum
    WHERE DEFPROJ_ID = defprodid;
    COMMIT;
    END UPDATE_USER_PROJMGR;
    /Here's my Perl script callable stmt:
    my $sth2 = $dbh->prepare(q{CALL UPDATE_USER_PROJMGR(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)});
    $sth2->execute($reglegal,$netcredloss,$expreduc,$stratgoal,$audcomp,$revgen,$cacs,$custit,$custimp,$callmgt,$calltrkl,$citlink,$deskt,$dialer,$dri,$engineering, $imaging,$ipdt,$mframe,$miscoth,$mortserv,$mortweb,$nonmortserv,$origpltfrm,$qualmap,$dataware,$servapp,$sbdev,$websvcg,$projmgr,$status,$itprojtype,$itprojnum)or do {
    print('err', "<img src='../spacer.gif' width='1' height='150'>ERROR: Could not execute SQL! Error: " . $dbh->errstr);
               };and the values getting passed:
    Holly Spradlin
    Withdrawn
    PRF
    1222
    Y
    Y
    N
    N
    Y
    Y
    Y
    N
    Y
    N
    N
    N
    Y
    N
    N
    N
    N
    N
    Y
    Y
    Y
    N
    N
    N
    N
    N
    N
    N
    NI get no compile errors or anything until I submit the form to update.
    Any help would be appreciated...if I get it solved, I'll reply right away - thanks.

    try manually executing the procedure to check for the
    errors
    SQL> execute UPDATE_USER_PROJMGR('Holly
    Spradlin','Withdrawn','PRF',1222,'Y','Y','N','N','Y',
    Y','Y','N','Y','N','N','N','Y','N','N','N','N','N','Y'
    ,'Y','Y','N','N','N','N','N','N','N','N');3360 is right you have only supplied 33 parameters
    while your procedures requires 34 parameters.ok, did this and did get the error:
    ERROR at line 1:
    ORA-06550: line 1, column 7:
    PLS-00306: wrong number or types of arguments in call to 'UPDATE_USER_PROJMGR'
    ORA-06550: line 1, column 7:but I wonder why I can't specify the ID value as my sequence's currval - ?
    Let me doublecheck my sequence.
    OK, I got it!!! thanks, guys, for all your help!!
    I just needed to back to the callable statement in the perl script itself and add the last ID param.
    Thanks for pointing that out!!
    Message was edited by:
    user515689

  • Oracle stored proc problem

    HI, I have created a stored proc in oracle similar below:
    CREATE OR REPLACE PACKAGE PACK_REFCURSOR_NHM_TRANSACTION AS
    TYPE TRANS_TableRows IS REF CURSOR
    RETURN NHM_TRANSACTION%ROWTYPE;
    PROCEDURE REFCUR_NHM_TRANSACTION (
    IN_sTMPACC IN string,
    IN_sITEM_TYPES IN string,
    OUT_TRANS OUT TRANS_TableRows);
    END PACK_REFCURSOR_NHM_TRANSACTION ;
    -- the above works fine
    --but this one below has the error when
    CREATE OR REPLACE PACKAGE BODY PACK_REFCURSOR_NHM_TRANSACTION
    AS
    PROCEDURE REFCUR_NHM_TRANSACTION (
    IN_sTMPACC IN string,
    IN_sITEM_TYPES IN string,
    OUT_TRANS OUT TRANS_TableRows) IS
    BEGIN
    OPEN OUT_TRANS FOR
    SELECT T.TRANSACTION_ID, T.TRANSACTION_TYPE,
    T.TRANSACTION_DATE, T.TRANSACTION_TIME,
    T.ITEM_CODE, 0 OE_DETAIL_ID,
    T.QUANTITY, T.LIST_PRICE, T.DISCOUNT, T.SALE_PRICE,
    T.GST_AMOUNT, 'I'INSURER_TYPE
    FROM NHM_TRANSACTION T
    WHERE DISPENSED_FLG = 'Y'
    AND T.ACCOUNT_ID = IN_sTMPACC
    AND T.TRANSACTION_TYPE IN ('01','02', '09')
    AND NVL(T.STATUS,'F') != 'C'
    AND T.BILLED_FLG = 'N'
    AND T.ITEM_TYPE IN (IN_sITEM_TYPES)
    AND T.BILL_ITEM_FLG = 'Y'
    UNION ALL
    SELECT T.OE_TRANSACTION_ID TRANSACTION_ID, TRANSACTION_TYPE,
    T.TRANSACTION_DATE,
    T.TRANSACTION_TIME, NVL(T.ITEM_CODE,T.PACKAGE_CODE)
    ITEM_CODE, T.OE_DETAIL_ID,
    T.QUANTITY, T.LIST_PRICE, T.DISCOUNT, T.SALE_PRICE,
    T.GST_AMOUNT, 'S' INSURER_TYPE
    FROM NHC_OE_TRANSACTION T, NHC_MASTER_ITEM M, NHM_PACKAGE P
    WHERE T.ACCOUNT_ID = IN_sTMPACC
    AND T.ITEM_CODE = M.ITEM_CODE(+)
    AND T.PACKAGE_CODE = P.PACKAGE_CODE(+)
    AND (DECODE(T.ITEM_CODE,NULL,P.BILL_OPTION,M.BILL_OPTION) in
    ('P','O','F'))
    AND NVL(T.STATUS,'F') != 'C'
    AND T.BILLED_FLG = 'N'
    AND ((T.TRANSACTION_TYPE = '09' AND STATUS IN ('P','R'))
    OR T.TRANSACTION_TYPE IN ('01','02','11','12', '10'))
    AND T.BILL_ITEM_FLG = 'Y'
    AND T.ITEM_TYPE IN (IN_sITEM_TYPES) ;
    END REFCUR_NHM_TRANSACTION ;
    END PACK_REFCURSOR_NHM_TRANSACTION ;
    --this gives error: PLS-00382: expression is of wrong type
    but when i tried to change the query similar to this:
    OPEN OUT_TRANS FOR
    SELECT T.*
    FROM NHM_TRANSACTION T
    WHERE DISPENSED_FLG = 'Y'
    AND T.ACCOUNT_ID = IN_sTMPACC
    AND T.TRANSACTION_TYPE IN ('01','02', '09')
    AND NVL(T.STATUS,'F') != 'C'
    AND T.BILLED_FLG = 'N'
    AND T.ITEM_TYPE IN (IN_sITEM_TYPES)
    AND T.BILL_ITEM_FLG = 'Y' ;
    --that worked fine. what i found out is the proc doesn't seem
    to work with complicated queries. instead it works only in
    something similar to SELECT T.*? and not when individual fields are
    extracted? I can't understand why? can anyone help me with this>
    thanks.

    I think what is hapenning is that you are declaring the
    reference cursor in your package spec as a "strong" type as a
    rowtype of table NHM_TRANSACTION. However, in your OPEN FOR SELECT
    statement, you are selecting columns that do not exist in the the
    NHM_TRANSACTION table, such as 0 OE_DETAIL_ID, 'I'INSURER_TYPE,
    etc.
    You would be much better off to declare your reference cursor
    as a "weak" type so that your OPEN FOR SELECT statement actually
    defines the return structure:
    TYPE TRANS_TableRows
    IS REF CURSOR;
    In other words, leave off the RETURN NHM_TRANSACTION%ROWTYPE
    in your ref cursor declaration, and you would probably be OK
    (assuming, of course, that all of the columns selected in your
    UNION statements are like data types).
    Phil

  • Stored Proc running twice using DBMS_Scheduler

    Hello all,
    I have a vb front end that calls a main stored proc which submits scheduler jobs to execute several stored procs asynchronously. Everything is working, except the part that the several stored procs are running twice. In the troubleshooting, I have eliminated the front end from being the culprit and the stored procs themselves. Essentially, when I call the stored proc using dbms_scheduler.create_job, it runs twice, even manually. I am about at wits end trying to figure out why: Using Oracle 11gR2
    I started off setting up the programs
    begin
    --create program
    dbms_scheduler.create_program
    ( program_name => 'prog_name'
    ,program_type => 'STORED_PROCEDURE'
    ,program_action => 'usp_sub_proc_1'
    ,number_of_arguments => 8
    ,enabled => FALSE
    dbms_scheduler.DEFINE_PROGRAM_ARGUMENT
    ( program_name=> 'prog_name'
    ,argument_position=>1
    ,argument_name => 'name'
    ,argument_type=>'VARCHAR2'
    /*the remaining 7 arguments are in code but not display for space reasons*/
    dbms_scheduler.enable('prog_name');
    end;Then the main stored proc executes this code:
    declare v_job_name varchar2(100);
        v_1 varchar(50) := 'All';
        v_2 varchar(50) := 'All';
        v_3 varchar(50) := 'All';
        v_4 varchar(50) := 'All';
        v_5 varchar(50) := 'TEST';
        i_6 integer := 1;
        v_7 varchar(50) := 'TEST_NE';
        ts_8 timestamp := current_timestamp;
    begin
        v_job_name := 'uj_dmo_1';
    dbms_scheduler.create_job (v_job_name
                                            ,program_name => 'prog_name'
                                            ,job_class => 'UCLASS_1'
                                            ,auto_drop => TRUE
    --set parameters
    dbms_scheduler.set_job_argument_value(v_job_name,1, v_1);
    dbms_scheduler.set_job_argument_value(v_job_name,2, v_2);
    dbms_scheduler.set_job_argument_value(v_job_name,3, v_3);
    dbms_scheduler.set_job_argument_value(v_job_name,4, v_4);
    dbms_scheduler.set_job_argument_value(v_job_name,5, v_5);
    dbms_scheduler.set_job_argument_value(v_job_name,6, to_char(i_6));
    dbms_scheduler.set_job_argument_value(v_job_name,7, v_7);
    dbms_scheduler.set_job_argument_value(v_job_name ,8, to_char(ts_8));
    --enable job
    dbms_scheduler.enable(v_job_name);
    --execute job
    dbms_scheduler.run_job(job_name => v_job_name , use_current_session => FALSE);
    end;
    ...And this is where I get the double execution of the job, but I am just not seeing it in my syntax, dba_scheduler_jobs, logging, etc. Any help is greatly appreciated, thanks!!

    Well apparently I will not win any Captain Obvious awards;
    With 34MCA2K2's response with "what doesn't work" for some reason turned the light on. After some more testing here is what I found.
    This code works as expected :
    Exhibit A
    begin
    dbms_scheduler.create_job (job_name =>'TESTER'
                                   ,job_type => 'PLSQL_BLOCK'
                                   ,job_action => 'declare test1 integer := 1; begin test1 := test1 + 5; end;'
                                   ,auto_drop => True
       /*dbms_scheduler.enable('TESTER');   */
       dbms_scheduler.run_job(job_name => 'TESTER', use_current_session =>FALSE);   
    end;As does this:
    Exhibit B
    begin
    dbms_scheduler.create_job (job_name =>'TESTER'
                                   ,job_type => 'PLSQL_BLOCK'
                                   ,job_action => 'declare test1 integer := 1; begin test1 := test1 + 5; end;'
                                   ,auto_drop => True
       dbms_scheduler.enable('TESTER');  
      /*dbms_scheduler.run_job(job_name => 'TESTER', use_current_session =>FALSE);    */
    end;Exhibit A will create the job and is visible in the schedulerjobs view, and the RUN_JOB will execute it even when not enabled, but the pl/sql will not drop the job.
    Exhibit B will create the job and once enabled, executes the job and then drops from schedulerjobs view.
    Therefore, my desired results for running the jobs once asynchronously and dropping immediately is....
    begin
        v_job_name := 'uj_dmo_1';
    dbms_scheduler.create_job (v_job_name
                                            ,program_name => 'prog_name'
                                            ,job_class => 'UCLASS_1'
                                            ,auto_drop => TRUE
    --set parameters
    dbms_scheduler.set_job_argument_value(v_job_name,1, v_1);
    dbms_scheduler.set_job_argument_value(v_job_name,2, v_2);
    dbms_scheduler.set_job_argument_value(v_job_name,3, v_3);
    dbms_scheduler.set_job_argument_value(v_job_name,4, v_4);
    dbms_scheduler.set_job_argument_value(v_job_name,5, v_5);
    dbms_scheduler.set_job_argument_value(v_job_name,6, to_char(i_6));
    dbms_scheduler.set_job_argument_value(v_job_name,7, v_7);
    dbms_scheduler.set_job_argument_value(v_job_name ,8, to_char(ts_8));
    /*enable job*/
    dbms_scheduler.enable(v_job_name);
    /*execute job (Do not execute the code below, it will lead to multiple executions)
    dbms_scheduler.run_job(job_name => v_job_name , use_current_session => FALSE); */
    end;

  • Need to update the xml clob-pls pls help!

    my xml is stored as blob, i can view,do string manipulation and churn out data etc...but now i have a request where i need to find some particualr node and modify its value.
    here is what i m doing now which works.
    select compressor2.blob_decompress2(xml_data) into l_blob
    from tablename where id=2008890;
    clob_data := utl2.blob2clob(l_blob);
    parser := xmlparser.newParser;
    xmlparser.parseClob(parser, clob_data);
    doc := xmlparser.getDocument(parser);
    nl := xmldom.getElementsByTagName(doc, '*');
    len := xmldom.getLength(nl);
    dbms_output.put_line('Length : ' || len);
    tag_name := 'Node Verson : ' || xmldom.getVersion(doc)|| '<br>';
    for counter in 0..len-1
    loop
    tag_name := '';
    node := xmldom.item(nl, counter);
    parent_node := xmldom.getParentNode(node);
    child_node := xmldom.getfirstchild(node);
    tag_name := 'Parent Name : ' || xmldom.getNodeName(parent_node) || '<br>';
    tag_name := tag_name || 'Node Name : ' || xmldom.getNodeName(node) || '<br>';
    IF xmldom.getNodeType(child_node) = xmldom.TEXT_NODE THEN
    tag_name := tag_name || 'Node Value : ' || xmldom.getNodeValue(child_node)|| '<br>';
    ELSE
    tag_name := tag_name || 'Node Value : Node has child.No Node value.' || '<br>';
    END IF;
    tag_name := tag_name || 'Node Type : '||xmldom.getNodeType(child_node) || '<br>';
    ele_name := xmldom.getDocumentElement(doc);
    child_nl := xmldom.getElementsByTagName(ele_name,'*');
    IF xmldom.isNull(doc) THEN
    htp.p('Document is null');
    ELSE
    htp.p(tag_name);
    END IF;
    end loop;
    b_blob := utl.clob2blob(tag_name);
    select compressor2.blob_compress2(b_blob) into b_blob2 from dual;
    insert into xupdate values (2008890,b_blob2);
    i still need to know how to update the xml clob... i want to know how to find the particular node and then modify the clob with the new value. rest i can update the table.
    pls pls help..on this.

    my oracle version.
    10.2.0.1.0
    i want to update here..
    <?xml version="1.0" encoding="utf-8"?>
    <TestData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
         <Status>CompletedNormally</TestCompletionStatus>
         <ComputerName>DUILT10</ComputerName>
         <StartTime>2008-03-19T15:12:23</StartTime>
    ---Some more noded----
    <Parameters>
              <RangeMeasured>
                   <Name>PDissBol-5[C]</Name>
                   <Min>1.22</Min>
                   <Max>1.36</Max>
                   <Units>W</Units>
              </RangeMeasured>
              <TextMeasured>
                   <Name>ComputerName</Name>
                   <Value>DUILT10</Value>
              </TextMeasured>
              <RangeMeasured>
                   <Name>TrackError25[C]To-5[C]</Name>
                   <Min>0.031</Min>
                   <Max>0.041</Max>
                   <Units>dB</Units>
              </RangeMeasured>
              <RangeMeasured>
                   <Name>Power-5[C]</Name>
                   <Min>1.988</Min>
                   <Max>1.061</Max>
                   <Units>dBm</Units>
              </RangeMeasured>
    ---some more noded---
    </Parameters>
    </TestData>
    the file is huge.
    what i need to chang==>
    I 1st need to find this PDissBol-5[C] within the <Parameters> Node and then change its <Min> and <Max>
    and then update the table.
    pls pls suggest.

Maybe you are looking for