Why rollback is not working....

it's 10g
as far as I know, dbms_scheduler.create_job is not a DDL. So why this is saving insert ...
SQL*Plus: Release 10.2.0.3.0 - Production on Sat May 10 20:58:31 2008
Copyright (c) 1982, 2006, Oracle.  All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
SQL> @y
SQL> drop table junk_34;
Table dropped.
SQL> create table junk_34(f varchar2(10));
Table created.
SQL> set serveroutput on
SQL> declare
  2   command varchar2(20000) ;
  3    job_name varchar2(200) := 'TEST';
  4   temp_name varchar2(200) := DBMS_SCHEDULER.GENERATE_JOB_NAME ;
  5  begin
  6   command := 'BEGIN null; END;';
  7   insert into junk_34 values('a_value');
  8  dbms_scheduler.create_job(
  9    job_name => temp_name,
10    job_type => 'PLSQL_BLOCK',
11   job_action => command,
12    start_date => systimestamp,
13    enabled => true);
14  dbms_output.put_line(command);
15  rollback;
16  end;
17  /
BEGIN null; END;
PL/SQL procedure successfully completed.
SQL> set line 2000
SQL> select * from junk_34;
F
a_value
SQL>
SQL>

it wont even compile with autonomous_transaction
Read my comments carefully. I said you should create "your own wrapper package for the dbms_scheduler that simply surrounds each call to dbms_scheduler with an autonomous transaction". I did not say "stick your code inside an anonymous pl/sql block with an autonomous transaction pragma".
Stripped to the bare minimum, this looks about right - but since I've only spent a few minutes writing it, I'm not going to guarantee that it's doing anything other than giving you the general idea:
create or replace package my_scheduler
as
     procedure create_job(
          i_job_name     in     varchar2,
          i_job_type     in     varchar2,
          i_job_action     in     varchar2,
          i_start_date     in     timestamp with time zone,
          i_enabled     in     boolean
end;
create or replace package body my_scheduler as
procedure create_job (
     i_job_name     in     varchar2,
     i_job_type     in     varchar2,
     i_job_action     in     varchar2,
     i_start_date     in     timestamp with time zone,
     i_enabled     in     boolean
is
     pragma autonomous_transaction;
begin
     dbms_scheduler.create_job(
          i_job_name,
          i_job_type,
          i_job_action,
          i_start_date,
          i_enabled
end;
end;
/If you've got your privileges sorted out correctly, you should be able to create this package, then make a call to my_scheduler.create_job rather than dbms_scheduler.create_job.
Regards
Jonathan Lewis
http://jonathanlewis.wordpress.com
http://www.jlcomp.demon.co.uk

Similar Messages

  • Why rollback doesn't work?

    hello,
    I am mantaining a servlet application with Tomcat and MySQL 4.0.16 .
    Here is a part of the code that is giving me lots of problems with concurrent users:
    public void saveUpdate(String gameName, int IDAzienda, int periodo) throws ClassNotFoundException, SQLException, NamingException, Exception {
        Connection con = null;
        PreparedStatement pstmt = null;
        ResultSet rs = null;
        Statement stmt = null;
        try {
            con = DBConnect.connect("DB");
            con.setAutoCommit(false);
            // many updates
            con.commit();
            con.setAutoCommit(true);
            con.close();
            catch ( SQLException sqle ){
            con.rollback();
            throw sqle;
        finally {
             if ( rs != null ){
                  try {rs.close();}
                  catch ( Exception e ) {  }
                  rs = null;
              if ( stmt != null ){
                  try {stmt.close();}
                  catch ( Exception e ) {  }
                  stmt = null;
              if ( pstmt != null ){
                   try {pstmt.close();}
                   catch ( Exception e ) {  }
                   pstmt = null;
              if ( con != null ){
                    try {con.close();}
                    catch ( Exception e ) { }
    }When concurrent users click on the submit button on the same istant to read/write on the db (there are many more similar methods called by different servlets), sometimes something goes wrong and it throws an exception (this is a problem I will set out later in the Servlet forum).
    The problem with above code is that when such an event occur, the tables stay modified and are saved with incoherent values.
    I am using InnoDB tables, so rollback() should be fully implemented.
    Do you think that I should move con.rollback() from the catch block to the finally block? anyway, why is this not working?
    thank you
    alessandro

    thanks for your quick replies.
    1. connections are always in setAutocommit(false)
    2. there are no DDL or other implicit commit statements
    so I guess too this is a locking problem. each method reads or updates the same 50 tables in a single transaction. what will happen if I use a SERIALIZABLE isolation level when 2 or more users are concurrent? will each method complete its transaction before another one is called?
    or do I have to LOCK manually the whole 50 tables at the beginning of each transaction? though I read that if a thread gets a LOCK, it automatically commits the changes made up to that point (also by other threads), so it might not be transaction-safe if one thread gets a LOCK while another one is still operating.
    alessandro

  • Unsure why this is not working?

    Can anyone give me a pointer as to why this is not working? I put the code from line 16 through 50 in the "...before displaying the page" additional pl/sql section of the wizard. The form wizard created the code from 5 through 15 and 51 through 55. The first error I understand because I think the wizard forgot to end the procedure correctly by saying "end beforeModuleDisplay;" instead of just putting "end;".
    If I am right, how can I fix this since the wizard is the one putting in this info? I tried putting the correct end statement in where I put the rest of my code, but that created even more errors.
    Error creating package SOCSBO_USER.ACCT_INFO
    Error creating package SOCSBO_USER.ACCT_INFO
    Line/ColumnError
    56/5PLS-00103: Encountered the symbol "PROCEDURE" when expecting one of the following: begin declare end exception exit for goto if loop mod null pragma raise return select update while <an identifier> <a double-quoted delimited-identifier> <a bind variable> << close current delete fetch lock insert open rollback savepoint set sql execute commit forall <a single-quoted SQL string> The symbol "declare" was substituted for "PROCEDURE" to continue.
    2128/5PLS-00103: Encountered the symbol "END" when expecting one of the following: begin function package pragma procedure form
    -- PACKAGE BODY SOCSBO_USER.ACCT_INFO
    -- created Monday 05-NOV-2001 16:52
    create or replace
    1 package body ACCT_INFO as
    2 --
    3 -- Created by ASAPP using WebDB at 15:16:46, Mar 04, 2002
    4 --
    5 procedure beforeModuleDisplay
    6 (
    7 p_block_name in varchar2,
    8 p_object_name in varchar2,
    9 p_instance in integer,
    10 p_event_type in varchar2,
    11 p_user_args in varchar2,
    12 p_session in out PORTAL30.wwa_api_module_session
    13 )
    14 is
    15 begin
    16 declare
    17 l_fs varchar2(200);
    18 l_cv varchar2(200);
    19 l_sv varchar2(200);
    20 l_lang varchar2(100);
    21 l_idx integer;
    22 begin
    23 l_lang := portal30.wwctx_api.get_nls_language;
    24 l_fs := p_session.get_value_as_varchar2(
    25 p_block_name => 'DEFAULT',
    26 p_attribute_name => '_FORM_STATE');
    27 l_cv := p_session.get_shadow_value(
    28 p_block_name => 'DEFAULT',
    29 p_attribute_name => 'A_ACCOUNT_COURSE',
    30 p_language => l_lang);
    31 l_sc := p_session.get_shadow_value(
    32 p_block_name => 'DEFAULT',
    33 p_attribute_name => 'A_ACCOUNT_SUBPROJECT',
    34 p_language => l_lang);
    35 if upper(l_fs) = 'UPDATE_AND_DELETE' then
    36 l_idx := row_function.get_index('COURSE_BOTTOM');
    37 if upper(l_cv) = 'Y' then
    38 p_form.items(l_idx).visible := 'Y';
    39 else
    40 p_form.items(l_idx).visible := 'N';
    41 end if;
    42 end if;
    43 if upper(l_fs) = 'UPDATE_AND_DELETE' then
    44 l_idx := row_function.get_index('SUBPROJECT_BOTTOM');
    45 if upper(l_sv) = 'Y' then
    46 p_form.items(l_idx).visible := 'Y';
    47 else
    48 p_form.items(l_idx).visible := 'N';
    49 end if;
    50 end if;
    51 exception
    52 when others then
    53 PORTAL30.wwerr_api_error.add(PORTAL30.wwerr_api_error.DOMAIN_WWV,'app','generic','SOCSBO_USER.ACCT_INFO.beforeModuleDisplay', p1 => sqlerrm);
    54 raise;
    55 end;
    56 procedure row_function
    REST OF CODE NOT RELEVANT

    Hello Albert,
    You open a new pl/sql block on line 16, but you have only one 'end' statement.
    You can correct this by adding another 'end' statement after line 55 or you can remove the inner PL/SQL block and place it in the procedure itself. Variables can be declared after 'is' on line 14. In your example it's better to do it this way. See example.
    Hope this helps...
    Nancy.
    Example solution 2:
    -- PACKAGE BODY SOCSBO_USER.ACCT_INFO
    -- created Monday 05-NOV-2001 16:52
    create or replace
    1 package body ACCT_INFO as
    2 --
    3 -- Created by ASAPP using WebDB at 15:16:46, Mar 04, 2002
    4 --
    5 procedure beforeModuleDisplay
    6 (
    7 p_block_name in varchar2,
    8 p_object_name in varchar2,
    9 p_instance in integer,
    10 p_event_type in varchar2,
    11 p_user_args in varchar2,
    12 p_session in out PORTAL30.wwa_api_module_session
    13 )
    14 is
    15 l_fs varchar2(200);
    16 l_cv varchar2(200);
    17 l_sv varchar2(200);
    18 l_lang varchar2(100);
    19 l_idx integer;
    20
    21 begin
    22
    23 l_lang := portal30.wwctx_api.get_nls_language;
    24 l_fs := p_session.get_value_as_varchar2(
    25 p_block_name => 'DEFAULT',
    26 p_attribute_name => '_FORM_STATE');
    27 l_cv := p_session.get_shadow_value(
    28 p_block_name => 'DEFAULT',
    29 p_attribute_name => 'A_ACCOUNT_COURSE',
    30 p_language => l_lang);
    31 l_sc := p_session.get_shadow_value(
    32 p_block_name => 'DEFAULT',
    33 p_attribute_name => 'A_ACCOUNT_SUBPROJECT',
    34 p_language => l_lang);
    35 if upper(l_fs) = 'UPDATE_AND_DELETE' then
    36 l_idx := row_function.get_index('COURSE_BOTTOM');
    37 if upper(l_cv) = 'Y' then
    38 p_form.items(l_idx).visible := 'Y';
    39 else
    40 p_form.items(l_idx).visible := 'N';
    41 end if;
    42 end if;
    43 if upper(l_fs) = 'UPDATE_AND_DELETE' then
    44 l_idx := row_function.get_index('SUBPROJECT_BOTTOM');
    45 if upper(l_sv) = 'Y' then
    46 p_form.items(l_idx).visible := 'Y';
    47 else
    48 p_form.items(l_idx).visible := 'N';
    49 end if;
    50 end if;
    51 exception
    52 when others then
    53 PORTAL30.wwerr_api_error.add(PORTAL30.wwerr_api_error.DOMAIN_WWV,'app','generic','SOCSBO_USER.ACCT_INFO.beforeModuleDisplay', p1 => sqlerrm);
    54 raise;
    55 end;
    56 procedure row_function
    REST OF CODE NOT RELEVANT

  • Why does abode not work on my galaxy tab2

    Why does abode not work on my galaxy tab 2?

    The games dont load they just say I need to update to the latest version or say that it is not compaterble with it.

  • Why does sound not work on my Mac Air?

    Why does sound not work on my Mac Air --all setting seem okay. OSX 10.9.2 operating systyem.

    Open System Preferences > Sound > Output
    Make sure the coorect output devices is selected and the Mute button is not checked.

  • Why youtube dose not work on my macbook pro 10.6.6?

    why youtube dose not work on my macbook pro 10.6.6 ?

    Double check you have the latest version of Adobe Flash.

  • Not sure why Message is not working on my ipad.

    Not sure why message is not work on my iPad. It works find on my iPhone.

    http://support.apple.com/kb/TS2755

  • I have an older iMac 5,1 and the disc drive no longer works. I was hoping that I could the Apple USB super drive as a replacement, but the info on the super drive page says compatible with iMac 2012 or later. Does anyone know why it would not work for me?

    I have an older iMac 5,1 and the disc drive no longer works. I was hoping that I could the Apple USB super drive as a replacement, but the info on the super drive page says compatible with iMac 2012 or later. Does anyone know why it would not work for me?

    A reply to similar question (Q & As , in product page Apple Store) says:
    "...dissable the internal reader hardware from devices setup. Then plug the external usb superdrive and that's it."  Answered by Enrique T from Lima Oct  25 2013.
    If you can locate an external Apple USB 'Air" superdrive for earlier model MacBook Air, that should work. The newer one for the Air is the same as for iMac, now.
    You may be able to use other brands of external USB optical drive with your older intel-based iMac, as some of them function capably. A few should also be able to see system discs or other bootable utilities on DVD.
    Hopefully this helps.
    Good luck & happy computing!

  • Why it is not working?

    hai all,
    i am new to jsp. please help me with the necessary corrections of the code given below.
    <%@ page import="java.io.*, java.sql.*" %>
    <%
         ResultSet rs;
         Class.forName("oracle.jdbc.driver.OracleDriver()");
         Connection Con=DriverManager.getConnection("jdbc:oracle:thin:@192.168.x.xx:1521:new","old","new");     
         Statement st=Con.createStatement();
    %>
    why it is not working
    Thanks in advance.
    by
    ramki.

    I think you have to put the variables definition (rs, st, con...) in a specific place like this, i mark with (*) what i changed:
    <%! (*)
    ResultSet rs; (*)
    Connection Con; (*)
    Statement st; (*)
    %> (*)
    <% (*)
    Class.forName("oracle.jdbc.driver.OracleDriver()");
    Con=DriverManager.getConnection ("jdbc:oracle:thin:@192.168.x.xx:1521:new","old","new");
    st=Con.createStatement();
    %>
    good luck,
    javi

  • Why facetime does not working with any carrier in u.s expect att although the iphone is factory unlocked

    why facetime does not working with any carrier in u.s expect att although the iphone is factory unlocked

    Facetime only works via WiFi. Are you trying to set up Facetime with a T-Mobile account?

  • Why ps3 is not working well with airport

    why ps3 does not work well wth the airport?

    If you are referring to online gaming, then PS3 like all non-apple devices uses upnp to open ports.
    Apple uses NAT-PMP to open ports.. East and West.. never the twain shall meet.
    If it is internal wireless issues.. that is different.. airport should be just like any other wireless router.
    If you tell us the issue we have more hope to help.

  • HT202853 I have many project made in move HD that are not updating to the new iMovie 10 on my new iMac.  Why is this not working as stated?  How do I get my projects back from backup after old iMac crashed?

    I have many projects made in imovie HD that are not updating to iMovie 10 on my new iMac.  Why is this not working as stated on the article HT202853?  How do I get my projects back from backup after old iMac crashed?

    According to:
    Update projects and events from previous versions of iMovie in iMovie (2014) - Apple Support
    you can update from iMovie versions 7, 8 and 9, but iMovie HD is iMovie 6.
    Maybe you can update in two steps, first from iMovie 6 to iMovie 7, 8 or 9 then to iMovie 10. 
    Geoff.

  • I re- start my ipad2 into a new one,to update into i0s7, why it is not working of loading?

    I re- start my ipad2 into a new one,to update into i0s7, why it is not working of loading? please help!!!

    The [c:set|http://java.sun.com/products/jsp/jstl/1.1/docs/tlddocs/index.html] tag is used to set a scoped attribute not request parameter. So when you write
    <sql:param value="${param.userid}" />You get null as there is no parameter named userid in the request. Try this
    <sql:param value="${userid}" />I would recommend you not to do database connectivity stuff in JSP, JSPs are the view layer of an application and they aren't supposed to be for doing business logic. Also since you are using a random userid, you might end up with multiple users with the same ID and IDs are generally supposed to be unique...

  • TS3297 I want to buy the double coins from the game subway surfers! But they told me to contact the itunes support! I don't know why it's not working.. Please help! iPhone 4ss

    I want to buy the double coins from the game subway surfers! But they told me to contact the itunes support! I don't know why it's not working.. Please help! iPhone 4ss

    These are user-to-user forums, you are not talking to Apple here. You can contact iTunes support via this page and ask them why the message is appearing : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page, then probably Purchases, Billing & Redemption

  • Cant restore iphone 3g 4.2.1 it would load half way threw then say unknown error why it is not working?

    cant restore iphone it would loa half way threw then say unknown error why is it not working and its a iphone 3g 4.2.1

    What is the exact error message you're getting?

Maybe you are looking for

  • SAP R/3 4.6B to SAP Enterprise UPGRADE landscape methodology

    My primary question involves the upgrade landscape and its relationship with SAP's  E-Buyer system. We're upgrading R/3 in Q2 of 05. In all past upgrades I've done, I've used parallel landscapes; the existing DEV -> QAS -> PRD landscapes stays the sa

  • Passing values to custom OVS dynamically

    Hi, I am trying to select the Address from a list of addresses available for an Account while creating Visit for that account. In Visit QC, I populate the Account field using the standard Account OVS. After this, I want to show the list of Addresses

  • Missing Images in Skin

    Hello all, I am not quite sure if this is the right category, but searching for skin showed the most threads in this one. I have a skin deployed as jar into an application. The skin is applied correctly to the JSF page and its components, except some

  • Change NETPR in TX. ME21N while saving

    Hi to all, I need to change the netpr of all items in tx. ME21N but while the document is saving, 'cause the user doesn't want the new calculated netpr in display. I've been trying to use EXIT_SAPMM06E* but i can't make them work, specially EXIT_SAPM

  • Linksys 1.0.0.0 VMS software and remote users

    We need to give remote access to this software.. Remote destop into the server hosting the VMS doesn't seem to work as although you can RD in and get the main console software running, you just get a black screen in the camera picture area in both. W