How to make pl/sql procedure not auto-commit?

I wish to be able to execute a create statement, and then rollback if there is a problem with any sql that follows. It seems that you cannot rollback? Why is this?
(My problem is that I wish to execute a series of sql statements and run a rollback if anything before it fails, including the creation of the table)
set serveroutput on;
declare
  rcount INTEGER;
PRAGMA AUTONOMOUS_TRANSACTION;
begin
  execute immediate 'create table bsdconv_s1stc_code (id number)';
  dbms_output.put_line('Table created successfully');
  rollback;
exception
  when others then dbms_output.put_line('Error while creating table. Probably already exists.');
end;

Ni hao, Dong Yage!
I think using procedure and handling on call you might be able to do it.
SQL> create table test (i int);
Table created.
SQL> insert into test values (1);
1 row created.
SQL> select * from test;
         I
         1
SQL> set serveroutput on;
SQL> declare
  2    rcount INTEGER;
  3  PRAGMA AUTONOMOUS_TRANSACTION;
  4  begin
  5    execute immediate 'create table bsdconv_s1stc_code (id number)';
  6    dbms_output.put_line('Table created successfully');
  7  --  rollback;
  8  exception
  9    when others then
10       dbms_output.put_line('Error while creating table. Probably already exists.');
11    rollback;
12  end;
13  /
Table created successfully
PL/SQL procedure successfully completed.
SQL> desc bsdconv_s1stc_code
Name                                      Null?    Type
ID                                                 NUMBER
SQL> select * from test;
         I
         1
SQL> insert into test values (2);
1 row created.
SQL> set serveroutput on;
SQL> declare
  2    rcount INTEGER;
  3  PRAGMA AUTONOMOUS_TRANSACTION;
  4  begin
  5    execute immediate 'create table bsdconv_s1stc_code (id number)';
  6    dbms_output.put_line('Table created successfully');
  7  --  rollback;
  8  exception
  9    when others then
10       dbms_output.put_line('Error while creating table. Probably already exists.');
11       rollback;
12       execute immediate 'drop table bsdconv_s1stc_code';
13  end;
14  /
Error while creating table. Probably already exists.
PL/SQL procedure successfully completed.
SQL> select * from test;
         I
         1
         2
SQL> rollback;
Rollback complete.
SQL> select * from test;
no rows selected
SQL> desc bsdconv_s1stc_code;
ERROR:
ORA-04043: object bsdconv_s1stc_code does not exist
On executing PL/SQL block secondly,
it raises exception, displays error messages and drops table
but main transaction is not rolled back.
This is because rollback belongs to only inseide of
AUTONOMOUS_TRANSACTION PL/SQL block.
Now, let us try using procedure.
SQL> grant create table to ushi;
SQL> create or replace
  2  procedure create_table
  3  is
  4   PRAGMA AUTONOMOUS_TRANSACTION;
  5   begin
  6     execute immediate 'create table bsdconv_s1stc_code (id number)';
  7     dbms_output.put_line('Table created successfully');
  8  exception
  9    when others then
10       dbms_output.put_line('Error while creating table. Probably already exists.');
11       execute immediate 'drop table bsdconv_s1stc_code';
12       raise;
13  end;
14  /
Procedure created.
SQL> select * from test;
no rows selected
SQL> begin
  2    insert into test values (1);
  3    create_table;
  4  exception
  5    when others then
  6      dbms_output.put_line('Error on Creating table or Transaction');
  7      rollback;
  8  end;
  9  /
Table created successfully
PL/SQL procedure successfully completed.
SQL> select * from test;
         I
         1
SQL> commit;
Commit complete.
SQL> desc bsdconv_s1stc_code
Name                                      Null?    Type
ID                                                 NUMBER
SQL> begin
  2    insert into test values (2);
  3    create_table;
  4  exception
  5    when others then
  6      dbms_output.put_line('Error on Creating table or Transaction');
  7      rollback;
  8  end;
  9  /
Error while creating table. Probably already exists.
Error on Creating table or Transaction
PL/SQL procedure successfully completed.
SQL> select * from test;
         I
         1
SQL> desc bsdconv_s1stc_code
ERROR:
ORA-04043: object bsdconv_s1stc_code does not exist

Similar Messages

  • How to make valuation type field not changeable  in delivery tab of PO

    Hai friends,
                    I am new to badis..please guide me to solve the issue...
    how to make valuation type field not changeable  in delivery tab of PO...
    The field shd be in display mode only ...actually...there  a badi has been used before
    to get valuation type from a ztable depending on material and plant...
    Now ..my requirement is that the user shd not change the default value brought from the ztable...

    Hi SRINIVAS,
    You can achieve this from BADI only if BADI is allows you to do this. You cannot achieve everything from a BADI. Check if there is any expoting field in the methods that can be ticked for making the field in display mode. If not then you cannot achieve this from BADI.
    The field you want to default to display is a standard or zfield. If z, then you can changethe attribute of the screen field to Output only.
    Regards,
    Manish

  • How to execute a SQL procedure in UNIX

    How to execute a SQL procedure in UNIX

    Check this out..
    -Sri
    << a.sql >>
    create or replace procedure junk(nout out varchar2) is
            x varchar2(20);
    begin
            select 'Sam' into x
            from dual;
            nout := x;
    end;
    << Shell script >>
    sqlplus -s / << DOC
    scott/tiger
    variable x varchar2(20);
    set autoprint on
    @a.sql
    begin
    junk(:x);
    end;
    exit
    DOC
    << Execution of Shell SCript >>
    # sh b.sh
    Procedure created.
    PL/SQL procedure successfully completed.
    X
    Sam

  • Help!!! How to make quicktime plugin do not display on top of the web page?

    Any one knows how to make quicktime plugin do not display on top of the web page??? I've tried to change the zIndex property using javascript, but it doesn't work.
    Because we have some widgets which are required to be moved to anywhere on the page, we use iframe to implement that, so it can display on top of quicktime plugin, but the plugin flickers sometimes when we do some operation on the widget which is on top of it.
    Anyone can helps me? Thanks in advance!!!
      Windows XP Pro  

    > Can you tell me how to set the script so that the
    lightbox image is
    > displayed
    > on mouseover instead of mouse click.
    Check the docs. Trent is usually very thorough in his
    instructions.
    Hint: I haven't studied it but it probably involves modifying
    one of DW's
    built-in Behaviors.
    Walt
    "ducati1" <[email protected]> wrote in
    message
    news:gkb906$qrd$[email protected]..
    > Wow that DW extension is just what I needed.
    > Thanks..
    > Can you tell me how to set the script so that the
    lightbox image is
    > displayed
    > on mouseover instead of mouse click.
    > I currently have the thumbnails set to insert the ALT
    text into a text box
    > on
    > mouse click.
    >

  • HT4642 ios numbers:how to make cell height variable with auto line brake setting ?

    ipad numbers; How to make cell height variable with auto line break setting?

    That's strange. I responded earlier and the whole message got trashed. Hence the test post before retyping the entire thing again.
    Thanks for the reply.
    The video clip is a single screen capture video clip. This is what I've found by playing around with this more.
    The original clip resolution is greater than 640x480. If I use QT Pro to convert the original clip to 640x480 and then use either Flip4Mac or PE7, then the resolution looks good.
    Just trying to figure out if should keep all workflow on the MacOS side. There are several different version of Flip4Mac. $49 gives me 640x480, but if I ever want to make it slightly larger then I would need to go with the $99 or HD version.
    I also tried to export to AVI with QT Pro and the import with Windows MovieMaker but it didn't work really good. I liked the simplicity (since PE7 hogs a lot of resources especially through VMWare).

  • Hi! Since I installed Mavericks, all the messages in mail I receive are marked as read, when they're not! Can anyone explain to me how to make them appear as not read, so I notice them? Thank's

    Hi! Since I installed Mavericks, all the messages in mail I receive are marked as read, when they're not! Can anyone explain to me how to make them appear as not read, so I notice them? Thank's

    I don't know if it will work, but try rebuilding the mailbox. This can take awhile if you have a lot of mail.
    Rebuild mailbox

  • PL/SQL procedure "Not Defined"

    I have created a PL/SQL procedure, compiled it successfully, and am trying to call it from
    an "onmouseover=" construction in the Link Attributes for a report column.
    I have created an application process entry for this procedure in Shared Components/Application Processes.
    When I place the mouse pointer over the column in the report I get an error stating
    the procedure is "Not Defined".
    I am trying to implement this onmouseover event in a manner similar to how it is implemented in the "Aria People, 0.92" packaged application I have downloaded from the Oracle/APEX web site. In the downloaded "Aria People, 0.92" application I have installed the onmouseover="ARIA_DETAIL(this,'#PERSON_ID#")" call works fine (on page 1 of the app).
    Interestingly, if I take the exact same call to the ARIA_DETAIL() procedure and place it in my application I also get a 'Not Defined' error on the ARIA_DETAIL() procedure.
    Clearly I am failing to do what is needed to have a PL/SQL procedure "Defined" for an APEX application. Can some kind soul please tell me what I have failed to do here?
    Thank you in advance.
    Jim Lewis

    Jim,
    Sorry to go to the basics but am I correct about the following?
    1. You created the pl/sql process as an ondemand process.
    2. You added the ARIA_DETAIL javascript function to the page on which your calling it.
    I'm just guessing but it sounds like you missed the second step there. Take a look at the application you got the code from and look at the Page Attributes. You should see some code in the HTML Header. That's what you need to add to your app.
    Dan

  • How to  make JTextArea rows and colums auto-increase?

    My test program is attached as below.
    The JTextArea can not enlarge itself when the text in a line is too long that some characters are hidden.When rows grows too many will also see the problem.
    How can I make the rows and columns auto-increase to meet the width or height of my text?
    -----My Test Demo----
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.color.*;
    import javax.swing.*;
    public class Test{
    public static void main(String[] args){
    JFrame f = new JFrame("My Editor");
    Container ct = f.getContentPane();
    JPanel jp = new JPanel();
    JTextArea ta = new JTextArea("My software.",10,30);
    JTextArea ta2 = new JTextArea("Hello,World!",10,30);
    jp.setPreferredSize(new Dimension(400,400));
    jp.setBackground(Color.green);
    jp.setLayout(null);
    jp.add(ta);
    ta.setBounds(100,100,150,200);
    ta.setOpaque(false);
    ta.setBorder(null);
    jp.add(ta2);
    ta2.setBounds(100,120,150,200);
    ta2.setOpaque(false);
    ta2.setBorder(null);
    // jp.addMouseListener(new MyMouseListener());
    ct.setLayout(new BorderLayout());
    ct.add(jp,BorderLayout.CENTER);
    f.addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent evt) {
    System.exit(0);
    f.setVisible(true);
    f.pack();

    This link to the Java Swing tutorial will show you how to add the JTextArea to a JScrollPane:
    http://java.sun.com/docs/books/tutorial/uiswing/components/simpletext.html#textarea
    It appears to me that you are new to Swing so you should read the entire tutorial "Creating a GUI using JFC/Swing" before asking any more question. The tutorial can be read online or downloaded from:
    http://java.sun.com/docs/books/tutorial/
    The download link for all tutorials on this page is near the bottom.

  • How to call PL/SQL procedure from Jdeveloper

    hai
    i am using JDeveloper 10g version 10.1.3. i am working on Web Application[JSF,ADF BC]. i had commit button in one form. when i click that button a PL/SQL procedure can be invoked.( the procedure is to check for primary key)
    how to do this
    thanks in advance
    C.R

    There are already some threads about calling PL/SQL from Java. E.g.: adf bc jsf application and database stored procedure
    Ronald

  • How to make top level navigation not refresh

    Hello Guys,
    I have a question concerning on my External Facing Portal, my boss wants that when I click on a tab or a link in the Top Level Navigation , to load the content in the Content Area without refreshing the whole page, What I want is that when I click on a tab or link of the Top Level Navigation , the Top Level Navigation and the MasterHead not to refresh and that the content be loaded and refreshed only in the Content Area. The only way I know to do this is by making a frameset of my page and to make the masterhead and toplevel navigation a frame and the detalied navigation a frame and the content area a frame, and in the links to put the target property to the name of the content area frame, but I don't know if this is possible to do in the portal, I see that all is embedded and I don't know how to make a frameset like this in the portal.
    Any highlights to solve this will sure be appreciated.
    Thanks
    Rewarding points will be given.
    Luis

    Hi,
       When you are implementing External Facing Portal, i think you have used Light Framework Page.  In Light Framework Page, only one Framework has been used, so when you click on the top level navigation, the whole page will get refresh, so there is no otherway as of my knowledge.  If you use standard framework page in portal, it is possible to do (i.e. the content area only get refresh)  and the concept of your External Facing Portal is eliminated here.
    Regards,
    Venkatesh. K
    /* Points are Welcome */

  • How to use pl/sql procedure or function as part of validate the entity obj?

    Hi,
    we are migrating from oracle forms to jdeveloper 11g.
    I have a req. that,i wanted to use oracle pl/sql procedure to validate a attribute in an entity created with ADF BC?
    Is it possible to implement this?
    And how to show the error message from pl/sql procedure?
    Regards
    Murali.

    Hi,
    It is possible by using a method validator for the entity attribute.
    Create a transient attribute 'X'.
    In the validation section of the attribute to be validate, choose method validator.
    In the Error Message tab set error message as {0}.
    Below the value for tokentoken should source.X (X is the transient attribute name)
    In the java code of method validator, call the stored procedure and set the value of transient attribute X with the error message from SP.
    Use setX("ErrorMessage").
    Regards,
    Srinidhi

  • How to call pl/sql procedure/function from XML

    Hi,
    I have a requirement to call pl/sql function/procedure from the RTF template. How can I do this?

    Hi,
    I have got the same requirement. We need to call the store PL/SQL procedure from the XML template to generate the fixedwidth files. Could you tell me if you are able to call PL/SQL procedure from XML template?
    Thanks,
    Ram

  • How to call Pl/sql procedure from form ?

    Hi all,
    I need to call a procedure from form after the user has pressed the button to invoke the sql procedure, can anyone please advise me on how to do it ?
    Thanks.
    Lim

    Hi,
    Thanks for your reply.
    yes, I have include in when-button-pressed trigger as
    AIC_PROC_AR_CCID_UPD;
    Below is my procedure :-
    CREATE OR REPLACE PROCEDURE AIC_PROC_AR_CCID_UPD(errbuf out Varchar2,
              retcode out Number ) is
    VAR_BUF VARCHAR2(240);
    Cursor C1 is
    SELECT CONCATENATED_SEGMENTS ACCT,
    SEGMENT5 SEG5
    FROM AIC_GL_COA AGC
    WHERE AGC.CODE_COMBINATION_ID IS NULL;
    Rec1 C1%RowType;
    BEGIN
    FOR Rec1 IN C1 LOOP
         BEGIN
         UPDATE AIC_GL_COA A SET ( DESCRIPTION, CODE_COMBINATION_ID, SEGMENT5 )=
         ( SELECT FFVT.DESCRIPTION, GLA.CODE_COMBINATION_ID, GLA.SEGMENT5
         FROM GL_CODE_COMBINATIONS_KFV GLA,
         FND_FLEX_VALUES_TL FFVT,
         FND_FLEX_VALUES FFV
         WHERE GLA.CONCATENATED_SEGMENTS = REC1.ACCT
         AND FFV.FLEX_VALUE = REC1.SEG5
         AND FFV.FLEX_VALUE_ID = FFVT.FLEX_VALUE_ID
         AND FFV.FLEX_VALUE_SET_ID = 1002673 )
         WHERE A.SEGMENT5 = REC1.SEG5 ;
         EXCEPTION
         WHEN NO_DATA_FOUND THEN
         FND_FILE.PUT_LINE(FND_FILE.OUTPUT, 'NO RECORD UPDATE !!');     
         END;
    END LOOP;
    COMMIT;
    RETURN;
    END;
    However, when I try to compile it, error prompt :-
    Error 306 at line 1, column 1
    wrong number or types of arguments in call to 'AIC_PROC_AR_CCID_UPD'
    Error 0 at line 1, column 1
    statement ignored.
    By the way, my form 6i is running at client site and connection to procedure in unix server. Will this is ok ?
    Thanks
    Rgds
    Lim

  • How to call PL/SQL procedure from PERL

    I have a requirement to create a PERL wrapper for few PL/SQL procedure.
    Can any one tell me how to call the procedures from PERL ?
    Thanks in advance.
    ....srini

    A quick Google search shows:
    http://www.saturn5.com/~jwb/dbi-examples.html#ora_sp

  • How to make a adf page not participate in session

    Hi,
    I am getting the session time out warning message in the login page ( the user is not logged in yet).  Below is the scenario.
    1. Login page is JSF (.jspx) page and is using a page template.
    2. ADF security is implemented in the application and anonymous role and other roles have been provided the access to the login page and page  template.  ( FYI the application uses a different template for the logged in users)
    3. Session time out and WARNING_BEFORE_TIMEOUT is configured in web.xml .
    3. In both the page and  template the jsp page directive session attribute is set to false.
         <jsp:directive.page contentType="text/html;charset=UTF-8" session="false"/>
    How to make the page not participate in session and avoid the session time out message and refresh of the page ?
    Thank you .
    Ranjith

    Hi Frank,
    This is a webcenter portal 11.1.1.8 application and there are sites built with webcenter that does not throw this message on the login page . What should be my approach not to get this message.
    What does "session=false" attribute mean  <jsp:directive.page contentType="text/html;charset=UTF-8" session="false"/> (<%@ page .. session="false" %> Creating a JSP Document
    As per the link  JSP - Directives   Specifies whether or not the JSP page participates in HTTP sessions .
    Any help is greatly appreciated.
    Thank you

Maybe you are looking for