Each procedure have commit statement

I call five procedure individually, and each procedure have commit statement from .net environment i.e. click event of submitt button call five procedure
but now i want only one commit statement for all five proceduce if all procedure successfully
executed.
suppose first two procedure successfully execute then third procedure raise some exception, in that case previously execute procedure data successfully comitted, but i want them rollback because all five procedure does not successfully execute.

What does this have to do with OCI? Sounds like a transaction control question...
The answer is to commit at the end of the transaction from the client code, and not at the end of each procedure call.

Similar Messages

  • How to execute commit statement in a procedure optionally?

    We have a procedure which has DML operations and at the end there is a commit statement.
    I want to execute commit statement optionally.
    Like, when procedure runs directly it must execute commit statement, but when this procedure is called from a trigger don't run commit.
    As you know commit operation is not allowed in triggers.
    How can I understant the code is triggered from a trigger or any other (manuel exec or from another procedure).
    I am looking for the reserved word that solve my problem. Like INSERTING, DELETING ....
    Serkan
    Thanks.

    Hi oraserkan,
    You do of course know it's dangerous to have a commit inside a procedure?
    Consider this:
    SQL> create table t (text varchar2(25))
    Table created.
    SQL> create or replace procedure p
    as
    begin
       insert into t(text)
           values ('Insert PROCEDURE');
       commit;
    end p;
    Procedure created.
    SQL> insert into t(text)
        values ('Insert SQL')
    1 row created.
    SQL> exec p
    PL/SQL procedure successfully completed.
    SQL> rollback
    Rollback complete.
    SQL> select * from t
    TEXT                    
    Insert SQL              
    Insert PROCEDURE        
    2 rows selected.You should instead clearly state the procedure has a commit by making it autonomous, and then have two procedures, one that commits, and one that don't
    SQL> drop procedure p
    Procedure dropped.
    SQL> drop table t purge
    Table dropped.
    SQL> create table t (text varchar2(25))
    Table created.
    SQL> create or replace procedure p_transactional
    as
    begin
       insert into t(text)
           values ('Insert PROCEDURE');
    end p_transactional;
    Procedure created.
    SQL> create or replace procedure p_autonomous
    as
       pragma autonomous_transaction;
    begin
       p_transactional;
       commit;
    end p_autonomous;
    Procedure created.
    SQL> insert into t(text)
        values ('Insert SQL')
    1 row created.
    SQL> exec p_autonomous
    PL/SQL procedure successfully completed.
    SQL> rollback
    Rollback complete.
    SQL> select * from t
    TEXT                    
    Insert PROCEDURE        
    1 row selected.
    SQL> drop procedure p_transactional
    Procedure dropped.
    SQL> drop procedure p_autonomous
    Procedure dropped.
    SQL> drop table t purge
    Table dropped.Regards
    Peter

  • Commit or no commit statement in procedure

    Hi all,
    i have two version of the same procedure.
    procedure A
    --loop
    ---fetch into record
    --update a flag as processed
    commit;
    end loopprocedure A'
    -- loop
    --fetch into record
    --update a flag
    end loop In procedure A, i do a commit after every row. In A', i do not issue any commit statement. Will oracle auto commit the changes done in A' after the procedure finishes?
    Because i realise in procedure A, it takes a long time finish. Whereas in A' it takes a relatively less time to finish.
    Any harm if i choose procedure A' ?

    Any harm if i choose procedure A' ?No.
    But this way I prefer to commit.
    Commit inside the loop surely slow down the performance.
    If it is a huge table, then commit after every few set of trasactions will be advisable.
    Procedure A
    loop
    fetch into record....
    update or whatever your task....
    end loop;
    "commit";
    end procedure A.

  • JDBC - Pl/SQL-Procedure or SQL-Statement???

    Hi,
    we have got the following problem:
    Our program is entirely written in Java. It has to communicate with an ORACLE 8i database (Version 8.1.7). The big question is whether to call pl/sql-procedures which include the sql-statement (select/ insert/update) or to write the sql-statements in the Java-code directly.
    We messure the time in our test-database. The procedure took twice the time of the direct statement, althoug the sql-statement had to be parsed each time.
    What is the better way: pl/sql-procedure or sql-statements? On which conditions depend the choose?
    (For your information: our statements aren't difficult. In our testdatabase aren't much datasources.)
    Here is a snippet of our code:
    1. PL/SQL-Prozedure:
    CallableStatement cs = conn.prepareCall("begin dbrb_test_pkg.test(?,?,?); end;");
    cs.registerOutParameter(1, OracleTypes.CURSOR);
    cs.registerOutParameter(2, OracleTypes.CURSOR);
    cs.registerOutParameter(3, OracleTypes.CURSOR);
    cs.execute();
    ResultSet rs1 = ((OracleCallableStatement)cs).getCursor(1);
    ResultSet rs2 = ((OracleCallableStatement)cs).getCursor(2);
    ResultSet rs3 = ((OracleCallableStatement)cs).getCursor(3);
    2. SQL-Statements directly in Java-Code:
    String statement1b = "SELECT bva_id, bva_datva FROM bva";
    ResultSet rs1b = stmt.executeQuery(statement1b);
    String statement2b = "SELECT brb_id, brb_datein FROM brb";
    ResultSet rs2b = stmt.executeQuery(statement2b);
    String statement3b = "SELECT bper_id, bper_nz1 FROM bper";
    ResultSet rs3b = stmt.executeQuery(statement3b);
    Thanks a lot.
    Claudia and Nicole

    this is a case-to-case basis.
    it's ok to use the Statement/PreparedStatement if you're constructing your SQL or DML (insert/update/delete) statements. like when you're WHERE condition is dynamically created. this can be done also in PL/SQL (CallabeStatement) but passing of data is very tedious for you.
    the PL/SQL is much better to use if all your SQL or DML statements are fixed. besides, this is easier to maintain. when you need to change a statement, you don't need to check the statement in SQL prompt then make the necessary changes in your java codes, then compile the class. when you're using PLSQL, you just need to change and recompile the PL you made. then presto! it's done. as long as you don't change the parameters the PL receives and sends, it should perfectly work with your java code. =)

  • How commit statement works

    Hi,
    I want to know the procedure of how commit statement executes.
    I have a transaction in which I have updated 10000 rows of table A having 10lakh records and after this update I am updating 1 row in table B having 1000 records.
    after both these update statement I am executing commit statement.
    so, how this commit will work? does it commits the data in sequential order of updation of table A and B or it will be parallel for both the tables? Does it take time to do the commit?
    Thanks

    Arjit wrote:
    Hi,
    I want to know the procedure of how commit statement executes.
    I have a transaction in which I have updated 10000 rows of table A having 10lakh records and after this update I am updating 1 row in table B having 1000 records.
    after both these update statement I am executing commit statement.
    so, how this commit will work? does it commits the data in sequential order of updation of table A and B or it will be parallel for both the tables? Does it take time to do the commit?
    Thankswhen all else fails Read The Fine Manual
    http://docs.oracle.com/cd/E11882_01/server.112/e25789/sqllangu.htm#sthref864
    http://docs.oracle.com/cd/E11882_01/server.112/e25789/transact.htm#sthref1302
    http://docs.oracle.com/cd/E11882_01/server.112/e25789/transact.htm#sthref1320

  • Possible to have if statement within filters code?

    Hi
    I have some filters set up, and have assigned some global vars to them, which I then use in my Filters code to display the filters:
    myText:Filters [globals.data.glow1, globals.data.stroke1, globals.data.shad1]
    Works perfectly.
    Now I want to assign a global var to each global filter var to determine if it should be shown or not.  So...
    globals.data.glow1On = true;
    globals.data.stroke1On = true;
    globals.data.shadOn = true;
    ... and then somehow incorporate these new vars into an if conditional to determine if the filter global vars get included in the myText:Filters code.
    However, I cannot seem to code the if conditional into the myText:Filters code correctly.
    I even tried seperating it out like so:
    if (globals.data.glow1On = true) {myText:Filters [globals.data.glow1];
    if (globals.data.stroke1On = true) {myText:Filters [globals.data.stroke1];
    if (globals.data.shad1On = true) {myText:Filters [globals.data.shad1];
    But Flash only makes the last filter true (kinda makes sense to me now why).
    Is there a way to do it without having to make an if conditional with 7 permutations?
    Cheers
    Shaun

A: Possible to have if statement within filters code?

You are not coding the conditional properly.  "=" is for assignment, "==" is for comparing equality.
if (globals.data.glow1On == true) {myText:Filters [globals.data.glow1];
if (globals.data.stroke1On == true) {myText:Filters [globals.data.stroke1];
if (globals.data.shad1On == true) {myText:Filters [globals.data.shad1];
Also, a conditional evaluates whether or not something is true, so for Boolean values you do not need to explicitly compare them...
if (globals.data.glow1On) {myText:Filters [globals.data.glow1];
if (globals.data.stroke1On) {myText:Filters [globals.data.stroke1];
if (globals.data.shad1On) {myText:Filters [globals.data.shad1];
Lastly, for what I see that you showed, the conditionals are all missing their closing brackets, and while you can use them, the brackets are not needed for single command conditionals...
if (globals.data.glow1On){ myText:Filters [globals.data.glow1]; }
if (globals.data.stroke1On){ myText:Filters [globals.data.stroke1]; }
if (globals.data.shad1On){ myText:Filters [globals.data.shad1]; }
OR
if (globals.data.glow1On) myText:Filters [globals.data.glow1];
if (globals.data.stroke1On) myText:Filters [globals.data.stroke1];
if (globals.data.shad1On) myText:Filters [globals.data.shad1];

You are not coding the conditional properly.  "=" is for assignment, "==" is for comparing equality.
if (globals.data.glow1On == true) {myText:Filters [globals.data.glow1];
if (globals.data.stroke1On == true) {myText:Filters [globals.data.stroke1];
if (globals.data.shad1On == true) {myText:Filters [globals.data.shad1];
Also, a conditional evaluates whether or not something is true, so for Boolean values you do not need to explicitly compare them...
if (globals.data.glow1On) {myText:Filters [globals.data.glow1];
if (globals.data.stroke1On) {myText:Filters [globals.data.stroke1];
if (globals.data.shad1On) {myText:Filters [globals.data.shad1];
Lastly, for what I see that you showed, the conditionals are all missing their closing brackets, and while you can use them, the brackets are not needed for single command conditionals...
if (globals.data.glow1On){ myText:Filters [globals.data.glow1]; }
if (globals.data.stroke1On){ myText:Filters [globals.data.stroke1]; }
if (globals.data.shad1On){ myText:Filters [globals.data.shad1]; }
OR
if (globals.data.glow1On) myText:Filters [globals.data.glow1];
if (globals.data.stroke1On) myText:Filters [globals.data.stroke1];
if (globals.data.shad1On) myText:Filters [globals.data.shad1];

  • COMMIT statement

    Hi Guys,
    I have a RFC function module which updates a field on the Portal side and no updates are done on the R/3 side. I pass parameters to the FM and it updates the field on the portal side.So do we need a COMMIT statement in this situation.
    IS COMMIT statement necessary for every BAPI or RFC function module. What are the situation under which a COMMIT statement is used.

    Hi,
    IF you are exporting a data from SAP to other system you doesn't need this but if you are importing a data from others systems to SAP you need to use the statement COMMIT WORK.
    COMMIT WORK is required for transactions developed externally to the R/3 System that change data in the R/3 System via BAPI calls.
    When you call BAPIs in your program that change data in the R/3 System, afterwards you must call this the FM "BAPI_TRANSACTION_COMMIT" to write the changes to the SAP database.                                                                 
    <b>Use function module BAPI_TRANSACTION_COMMIT to do this.</b>
    Regards.
    Marcelo Ramos

  • Error by using database procedure in select statement

    hi ,
    I have built a database procedure having one parameter with in out varchar type. that return value with some addition.
    i am using it with some column in select statement only for display purpuses but i am facing error by doing that in select statement. that procedure is working well with bind variable but not with select statement.
    plz help me how i can use a procedure in select statement. or can i do it or not.

    plz help me how i can use a procedure in select statement. or can i do it or not.A workaround could be to create a wrapper function for your procedure. One that only passes the input parameters and returns the output parameter.
    The simply call this function in your select which internally calls the procedure.

  • CALL PROCEDURE IN SQL STATEMENT

    Why we cant call a procedure inside SQL statement?

    Hitesh Nirkhey wrote:
    Hi Karthick_Arp
    as you said
    The procedure that is used inside a function cannot contain DDL or DML statements or COMMIT/ROLLBACK.
    Said that it does not make much sence to use a procedure within a function.IT make sense if we DECLARE FUNCTION AS PRAGMA AUTONOMUS_TRANSACTION
    then we can execute DDL or DML statements or COMMIT/ROLLBACK in that function.
    Regards
    HiteshBut why would you do that?

  • Why I Can't use procedure in select statement

    Why I Can't use procedure in select statement

    We can use function in select statement but we couldn't use procedure with one out parameters in select statement... You can use Function because they are designed for this but procedure are not. Functions can return value (without OUT parameter) which can be used in SELECT whereas procedures do not have such concept. As you can see in the above post you can not call even functions also if it has any out parameter.
    I have just trying to use procedure in select statement ..for this I require technical answer..The technical answer is because conceptually procedure is for doing set of operation, performning DMLs on the tables , whereas functions are for processing and producing a single result. Functions are basically for not using INSERT/UPDATE/DELETE in it. That is the reason they are allowed to be used in SELECT because conceptually they are not supposed to do any data changes.
    Regards,
    Avinash

  • Commit statement in badi method

    hi all,
    i am using commit statement in badi method save_data, it is put after function module,
    in function module i have used insert and update statement, if i do like that then the commit statement refresh the global data but update the table,
    if i create one perform inside function module and put commit statement in that perform, then it shows message update was terminated,
    i also want the global data for processing thats why i can't use commit statement after FM in method, please give Suggestion,
    Points will be awarded.

    Hi,
    sounds as if you call that FM in update task. Update function modules do not allow all actions. They should only include the neccessary SQL statements and must include any COMMIT.
    For more information read SAPDOCU of COMMIT WORK and everything of SAPS update concept (start immed. V1, start delayed V2 and so on).
    ATTENTION. Most BADIs designed to save customers data may be used several times and standard data may be saved after them. To avoid inconsistent data inside those BADIs normally no COMMIT should be done.
    Kind regards,
    HP

  • ALDSP 3.0 -- schema owner for stored procedure or SQL Statement

    Using ALDSP, I have a need to create a physical service based on a stored procedure or a SQL statement. I am wondering what will happen when I move to another deployment environment where the schema owner changes. In our QA and Prod environments, we have a different schema owner for all tables in the application (the DBAs believe this prevents unwanted updates to a prod environment). DSP elegantly supports this for normal table- and view-based physical services by mapping schemas through the DSP console after deployment. Will I get the same type of mapping capability for stored procedures and SQL statements? I noticed that I can add a SQL-based function to a physical service...is there a way to pass in the physical table name from that data service to the procedure or SQL statement?
    Thanks,
    Jeff

    Schema name substitution should work for stored procedures just like it does for tables. If it doesn't - report a bug.
    You don't get any help for sql-statement based data services - dsp doesn't parse the sql provided. One thing you could do is use the default schema (following the user of your connection pool), and not specify the schema in your sql-statement.

  • Counting the number of lines for each procedure in a package

    Hi,
    I would like to write a query on USER_SOURCE that can display the number of code lines for each procedure/function in a package.
    Is it possible to write such a query? Maybe by using analytical functions?
    for example in the following example i would like to count the lines between "PROCEDURE proc1 IS" and "END proc1;" and between "PROCEDURE proc2 IS" and "END proc2;"
    SQL> select text  from user_source where name='PKG_TEST' and type='PACKAGE BODY';
    TEXT
    PACKAGE BODY PKG_TEST IS
      PROCEDURE proc1 IS
      BEGIN
        update t1 set EDITION_NAME = 'AAAAAAA';
        commit;
      END proc1;
    PROCEDURE proc2 IS
      BEGIN
       update t1 set EDITION_NAME = 'AAAAAAA';
        commit;
      END proc2;
    END PKG_TEST;thanks for helping

    onedbguru wrote:
    Hopefully some idiot manager isn't trying to use this sort of thing to base their decisions on developer productivity. If so, they ARE idiots. Number of code lines NEVER, EVER, EVER!!! translates into an efficient application. If I were paid by the line, my code would look like:
    select
    1
    from
    dual
    Based on the idiocy of this method of determining "performance" I would get paid $5.00 at $1.00/line. And trust me, I saw this back in the 80's and 90's and saw similar idiotic code and had to clean up the mess. Most of it wasn't efficient code to start with let alone the number of lines generated.Or the other extreme, when the PHB firmly believed that execution efficiency was gained by reducing the number of lines of code. So instead of nicely formatted, easy to read code:
          *GET NEXT ORDER NUMBER                                                               
                EXEC SQL                                                                        
                     SELECT (MAX(ORDER_NUM) + 1)                                                
                     INTO   :NEXT-NUM:IND-NULL                                                  
                     FROM   PART_ORDER                                                          
                END-EXEC.                                                                       
                IF IND-NULL < 0                                                                 
                  MOVE 1 TO NEXT-NUM.                                                           
                EXEC SQL                                                                        
                     INSERT                                                                     
                     INTO    PART_ORDER                                                         
                            (ORDER_NUM,                                                         
                             ORIGIN_LOC,                                                        
                             ORDER_TYPE,                                                        
                             ORDER_STAT,                                                        
                             CREAT_TIME)                                                        
                     VALUES (:NEXT-NUM,                                                         
                             :LOC, 'R', 'O',                                                    
                             CURRENT TIMESTAMP)                                                 
                   END-EXEC.                                                                    
                MOVE NEXT-NUM TO MASK0.                                                         
                PERFORM HEADER-PROC THRU HEADER-EXIT.                                           
            CREATE-ORDER-EXIT. EXIT.                                                     You got this:
           *GET NEXT ORDER NUMBER
            EXEC SQL SELECT (MAX(ORDER_NUM) + 1) INTO :NEXT-NUM:IND-NULL FROM
            PART_ORDER END-EXEC. IF IND-NULL < 0 MOVE 1 TO NEXT-NUM. EXEC SQL INSERT
            INTO PART_ORDER (ORDER_NUM, ORIGIN_LOC, ORDER_TYPE, ORDER_STAT,
            CREAT_TIME) VALUES (:NEXT-NUM, :LOC, 'R', 'O', CURRENT TIMESTAMP)
            END-EXEC. MOVE NEXT-NUM TO MASK0. PERFORM HEADER-PROC THRU HEADER-EXIT.
            CREATE-ORDER-EXIT. EXIT.                 Oh, wait! See the same thing all the time in this forum ... not because someone thinks fewer lines = faster code, but simply because people are sloppy.
    INSERT INTO PART_ORDER(ORDER_NUM,ORIGIN_LOC,ORDER_TYPE,ORDER_STAT,CREAT_TIME) VALUES (:NEXT-NUM,:LOC, 'R', 'O',CURRENT TIMESTAMP) ;

  • URGENT!!! a way to find out if Oracle stored procedures have OUT parameters

    I'm having problemes properly creating a string for the prepareCall().
    so that i can call up a stored procedure in oracle.
    the problem is that some stored procedures have OUT parameters that I have to register, and some stored procedures don't.
    how can i find out if a stored procedure has an OUT parameter or not?
    So that i can format a string with one less ? for statements that don't,
    and one more ? for statements that do have an OUT parameter.
    is there such a method as boolean OUTparameterExist();
    or i'll take any suggestions.

    any other solutions?That was the solution. You don't need to execute any sql statement to get Database Meta Data. You just need a connection, which you use to get the DatabaseMetaData instance
    DatabaseMetaData dbmd = connection.getMetaData();then invoke any of the (numerous) methods to get the info you require
    ResultSet rs = dbmd.getProcedureColumns("mydb","myschema","myproc",null);
    while(rs.next()) {
      String name = rs.getString("COLUMN_NAME");
      if (rs.getShort("COLUMN_TYPE")==DatabaseMetaData.procedureColumnOut) {
        // column is an OUT parameter
    }Dave

  • Comment after the commit statement.

    Hi Everyone,
    Please do have a look at this.
    Commenting on COMMIT: Example The following statement commits the current transaction and associates a comment with it:
    COMMIT COMMENT 'In-doubt transaction Code 36, Call (415) 555-2637';
    Now where can I see that comment? What is the data dictionary, which will have this detail?
    Regards,
    BS2012.

    If you look into the document for the COMMIT statement you will see this.
    COMMENT Clause
    Specify a comment to be associated with the current transaction. The 'text' is a quoted literal of up to 255 bytes that Oracle Database stores in the data dictionary view DBA_2PC_PENDING along with the transaction ID if a distributed transaction becomes in doubt. This comment can help you diagnose the failure of a distributed transaction.

  • Maybe you are looking for