Understanding Transactions

Reading the forum I read this post:
You need to configure transactions in your EnvironmentConfig and when you create/open your containers. E.g.:
envConf.setTransactional(true);
container = manager.openContainer(cname, new XmlContainerConfig.setTransactional(true));
Then you need to use explicit transactions in your application and be prepared to receive and handle deadlock exceptions (handle them via retrying the operation, after aborting the transaction).
So my question is what are the rules. By this I mean when I open my container I am using the flag DBXML_TRANSACTIONAL. However in some cases when i perform just a query I do not explicitly create a transaction, is that bad? I guess the question is what methods must I use explicit transactions?
Next when I do explicitly create a transaction if I do it in this order:
txn = DBManager->Manager->createTransaction();
container = DBManager->Manager->openContainer(path, flags);
container.putDocument(txn, doc, ctx);
Is this bad?, Some of the examples imply the order should be open the container, create the transaction, then put the document.
Thanks
Jim

Jim,
A few general rules:
1. open/create containers separately from operations on them. Usually an application will open a container when it starts up and close/delete it when it shuts down. Unless you are running in a CGI script where it's unavoidable that is what you should do too.
2. use the DBXML_TRANSACTIONAL flag or XmlContainerConfig.setTransactional(true) when opening containers. If you do this you do not need an explicit transaction for the open/create operation.
3. when using any container- or XmlManager-based operation for which there is a variant that takes an XmlTransaction parameter you should specify one and be prepared to handle a deadlock exception and abort and retry the operation. This applies to read (e.g. query) as well as update (e.g. putDocument) operations.
A few more rules:
4. always start your transactional application single-threaded and be sure to run recovery on your Environment before any other thread or process can access it.
5. always attempt to shut down cleanly -- closing (deleting) containers, managers, and environment (in that order). Again, this should be single-threaded with no other threads inside of the BDB XML or DB API.
Regards,
George

Similar Messages

  • EJB 2 : Query in understanding Transaction Attribute NotSupported

    NotSupported
    The Container invokes an enterprise Bean method whose transaction attribute is set to NotSupported with an unspecified transaction context.
    I am having a query in understanding the above thing .Please let me know what does above mean and also what transaction context mean in the below :
    If a client calls with a transaction context, the container SUSPENDS the association of the transaction context with the current thread before invoking the enterprise bean's business method.
    Thanks in advance .
    Waiting for your replies .

    it means that the method must operate outside of an active transaction - in other words there will be no active transaction during its runtime. If there is an active transaction when the method is called, that transaction is "put on hold" until the "notsupported" EJB call finishes.

  • Understanding transaction log..

    Hi all,
    Is there a way I can understand about the transaction,
    I have tried using "dbcc(3604);dbcc log;" but that doesnt help much..
    After some searching i came to know to use SQLAnywhere, but couldnt find any link to download it.
    Is there any other way to view the log ?
    Any reference on this will also be helpful.
    Thanks in advance.

    Unless the database is configured for sql statement replication, the transaction log does not contain any query text that would be useful to your investigation.  The log contains records showing the changes made to the binary data stored on each page as the result of data modifications (DML) only.
    You might consider setting up auditing of cmdtext and waiting for the issue to happen again.  The audit tables would then contain the queries run.
    You might also consider posting a detailed description of the issue, we might be able to recognize it or give further suggestions on how to reproduce it.
    -bret

  • Please help me to understand Transaction option in SSIS container

    Hi experts,
     I am confused about Transaction option in SSIS container,
    1. Required - Start the transaction. What is mean that start transaction?
    2.Supported- join the transaction ..
    can you please help me to understand.
    Thanks

    I think Vaibhav already answered your question but here's more from my end.
    1. 
        Package - Transaction Option - Supported
        SEQC - Transaction Option - Supported
        3 Execute SQL Tasks - Transaction Option - Supported
    So, package / SEQC / SQL 1 / SQL 2 / SQL 3 doesn't involve in a transaction i.e. think of those tasks are not included in
    BEGIN TRANSACTION / COMMIT TRANSACTION
    Sequence Container
    --Execute SQL Task 1
    INSERT INTO dbo.t1 (a)   
    SELECT 10
    --Execute SQL Task 2
    INSERT INTO dbo.t1 (a) 
    SELECT 11
    --Execute SQL Task 3
    INSERT INTO dbo.t1 (a) 
    SELECT 'aa'
    When we execute package, it will insert 10, 11 values into table dbo.t1 and since there's an error in the 3rd statement, it'll fail
    2.  
        Package - Transaction Option - Required
        SEQC - Transaction Option - Supported
        3 Execute SQL Tasks - Transaction Option - Supported
    Now, package will Start a transaction since it's Transaction Option is "Required" , so now the SEQC (3 Execute SQL tasks) will
    be inside transaction / join the transaction because their transaction option is "Supported".
    Package - Information: Starting distributed transaction for this container. --BEGIN TRANSACTION 
    (You'll see this statement in Processing / Execution Results tab)
    SEQC
    --Execute SQL Task 1
    INSERT INTO dbo.t1 (a)   
    SELECT 21
    --Execute SQL Task 2
    INSERT INTO dbo.t1 (a) 
    SELECT 22
    --Execute SQL Task 3
    INSERT INTO dbo.t1 (a) 
    SELECT 23
    Package - Information: Committing distributed transaction started by this container. -- COMMIT TRANSACTION 
    (You'll see this statement in Processing / Execution Results tab)
    When we execute package, it will insert 21, 22, 23 values into table dbo.t1 and also you can see the START TRANSACTION /
    COMMIT TRANSACTION in the Exection Results tab are at the Package Level and not at the Sequence Container level.
    Without any change, if you change the value from 23 to 'aa' in the 3rd Execute SQL task then you'll see 
    Information: Aborting the current distributed transaction. statement in the 3rd Executed SQL Task in Execute Results tab
    which is at the Sequence container / Execute SQL task 3 level and it's because their Transaction option is Supported and so they
    joined the transaction 
    Please see the screenshot below that under Package, the START TRANSACTION but ABORT TRANSACTION is at Execute SQL task
    level
    3. 
        Package - Transaction Option - Supported
        SEQC - Transaction Option - Required
        3 Execute SQL Tasks - Transaction Option - Supported
    Please see the screenshot below that under Sequence Container, the TRANSACTION has started. Since the the Sequence container's
    parent (which is package) has not started any transaction and so the it started it's own transaction. 
    4. 
        Package - Transaction Option - Required
        SEQC - Transaction Option - Required
        3 Execute SQL Tasks - Transaction Option - Supported
    See the screenshot below which is same as first screenshot.
    Since Package's transaction property is set to "Required" and it's Parent to Sequence Container 
    and so package started the started the transaction, and  though Sequence container's transaction option is "Required", 
    it will not start a new transaction rather it "joins" the transaction that was already opened by it's Parent (Package). 
    Now, if we see the definitions what Supported and Required means - 
    Supported - Specifies that this container will not start a transaction. 
    However, it will participate in a transaction if the parent container started one. This is the default. (4th Example)
    Required - Specifies that this container will cause a new transaction to be started unless the parent container already has a transaction, 
     in which case, the parent’s transaction will be joined. (2nd and 3rd Examples)
    Narsimha

  • Understanding Transaction KDR

    Hi,
    I would like to know the conditions a PO/GR/IR scenario must meet in order to trigger a posting with transaction KDR.
    So far I have not been able to produce such posting during my testing.
    The explanation in SAP help is not sufficient for my understanding by any means. OSS Notes search and forum search did not enlighten me either.
    OB08 is maintained.
    I do have different exchange rates for GR and IR dates.
    I also overwrote the FX rate in MIRO on some attempts.
    I do have an account in OBYC - KDR.
    Can you please describe a scenario for me that would ultimately lead to KDR determination ?
    Thanks in advance.
    Falk

    Are you telling that app is able to see uncommited results?
    It would appear so, yes.
    Are you using NOLOCK hint in your queries by any chance?
    No. Or, at least not explicitly.
    Are you overriding the set isolation level by using an explicit setting to set isolation level to read uncommited from your app?
    I've tried many different isolation levels, including the default isolation level, but I did not try Read Uncommitted. All Isolation Levels yielded the same result.
    If you open two database connections then its two sessions
    Thanks. That's what I thought. Here is my connection string:
    "Data Source=(local)\SQL2012;Initial Catalog=[DB];User ID=sa;Password=[Password];MultipleActiveResultSets=True"

  • Trying to understand reasons for a FX loss

    Hi All,
    Firstly our LC is same as SC.
    We have run the exchange rate differences tool and it has posted a huge £30k loss against the expect gains. We need to understand where the loss has been driven from, i.e exact transactions involved.
    I can't seem to find any reports which give a break down of it's calculations?
    Separately, what we find worrying is that it revalued our stock (GBP) lower from the exchange rate calcuation when we have never bought stock in euros. We do sell to BP's who are set to Euros and I understand transactions are conducted therefore in FC, but how a GBP stock account managed to devalue after a posted stock take is beyond me.
    any ideas to these two questions? all help appreciated.

    Hi,
    It is better to get to the detailed differences to analysis. This can be done such as by query to list all transactions from JDT1 that related to a BP.
    May I assume your LC and SC are GBP?
    Thanks,
    Gordon

  • Handle transaction in web dynpro

    Hi,
    How to handle transaction in web dynpro applications which is using Adaptive RFC model ?
    Thanks,
    Teja

    Hello Teja,
    Please refer tutorial at https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/d352a790-0201-0010-5082-b1a608d22b6c.
    I hope it will help u to understand transaction handling in wd.
    Best Regards,
    Pankaj Sharma

  • Why is the transaction log file not truncated though its simple recovery model?

    My database is simple recovery model and when I view the free space in log file it shows 99%. Why doesn't my log file truncate the committed
    data automatically to free space in ldf file? When I shrink it does shrink. Please advice.
    mayooran99

    My database is simple recovery model and when I view the free space in log file it shows 99%. Why doesn't my log file truncate the committed
    data automatically to free space in ldf file? When I shrink it does shrink. Please advice.
    mayooran99
    If log records were never deleted(truncated) from the transaction log it wont show as 99% free.Simple recoveyr model
    Log truncation automatically frees space in the logical log for reuse by the transaction log and thats what you are seeing. Truncation wont change file size. It more like
    log clearing, marking
    parts of the log free for reuse. 
    As you said "When I shrink it does shrink" I dont see any issues here. Log truncation and shrink file is 2 different things.
    Please read below link for understanding "Transaction log Truncate vs Shrink"
    http://blog.sqlxdetails.com/transaction-log-truncate-why-it-didnt-shrink-my-log/

  • Is pipeline transactional?

    Hi all!
    I try to understand transactional aspect of ALSB.
    Simple question: is it possible to create proxy service which transport is WebService/SOAP, which pipeline consists of several Service Callout nodes, and all these calls are in one transaction?
    Edited by Butyrkin at 09/12/2007 6:33 AM

    The response pipeline is in the same transaction than the request pipeline only if the inbound transport is synchrounous transactional. This only the case for Tuxedo transport today.
    In general I don't recommend using the response pipeline for transactional calls.
    The route node is in the same transaction than the request pipeline (if QOS exactly once).
    In your specific case the EJB should be in the same transaction than the request pipeline. We have test cases covering this so I doubt there is a bug. Maybe your EJB starts a new transaction when it is invoked? This is very weird.
    Gregory Haardt
    ALSB Prg. Manager
    [email protected]

  • Error in BOR Method

    Hi Experts,
    I need to update Infotype 2002 (Employee Attendance) in travel request approval work flow.
    For that I  am using set of standard BAPI 's
    "BAPI_EMPLOYEE_ENQUEUE"
    "HR_INFOTYPE_OPERATION"
    "BAPI_EMPLOYEE_DEQUEUE"
    But I am getting the error
    The exception 'CX_HRPA_INVALID_PARAMETER' was raised, but it was not caught
    anywhere along
    the call hierarchy.
    Since exceptions represent error situations and this error was not
    adequately responded to, the running ABAP program
    'CL_HRPA_RESOLVE_EXCEPTION=====CP' has to be
    terminated.
    When I am using same code in program, It's working fine without any error.
    can anyone suggest me , why this error is in BOR method and how to solve it.
    Thanks in advance.
    Regards,
    Priya

    Dear Vimal,
    I checked Note 1087428.
    That note says :
    You try to use transaction PA30 to create infotype 0706. In the run up, you did not use transaction PA40 to plan for the relevant personnel number. Therefore, infotype 0710 does not exist.
    Upto my understanding, transaction PA40 is for employee action, PA30 for employee master data maintainance and PA20 for employee master data display. so i have to use PA30 transaction for master data maintanance.
    For master data maintainance there is group of SAP standard function modules,
    BAPI_EMPLOYEE_ENQUEUE
    HR_INFOTYPE_OPERATION
    BAPI_EMPLOYEE_DEQUEUE
    If we use these function modules, they are same as PA30 transaction.
    When I used these FMs in my report program, they are working fine as their behaviour.
    But when i used these FMs in BOR method in Work Flow, FM 'HR_INFOTYPE_OPERATION' is throwing dump.
    I asked this to SAP, they reply that they didn't release FM 'HR_INFOTYPE_OPERATION' for custom programs, so they will provide any support on this problem.
    So I did work around for the same : I created one FM and inside FM i m calling BDC. That's working fine.
    Thanx to all for help.
    Regards,
    Priya

  • Reg:cats bapi

    hi all,
    can u pls help me in this?
    i have no idea abt bapi.can u pls explain the work functionality of bapi and difference between between bapi and function module.
    and also explain  
    how to use this bapi to upload the data into cats BAPI_CATIMESHEETMGR_INSERT .
    if possible send me the code also...
    thanks & regards
    rahul..

    Hello Rahul
    BAPIs enable you to access so-called business objects (like the CATS timesheet) in SAP from external systems.
    In contrast to "normal" function modules BAPIs have a holistic approach of accessing the business object.
    What does this mean? You may find a normal function module which enables you to insert records into timesheets, too. However, there is no guarantee that this fm takes care of all necessary consistency checks. The BAPI takes care of this.
    Basically, think of a BAPI as a "Dialog with dialog". The BAPI does more or less the same like the corresponding transaction (here: CAT2). In order to understand the mandatory input for the BAPI you must understand transaction CAT2.
    For sure you will find plenty of sample coding if you search the SDN for the BAPI name.
    Regards
      Uwe

  • R/3 Data Source for SEM BCS

    Hi Guys,
    I am using 0FI_GL_4 data source of R3 for SEM BCS.Am i right in doing so,please guide.
    As per my understanding transaction data has to be taken to BCS for consolidation and hence this is the relevent data source.
    Please provide comments on my understanding.
    We are working in the following enviornment:
    R3 version ECC6.0
    SEM BCS ver 6.0
    BW ver 7.0
    Best Regards
    Amit

    Hi Amit,
    It is enough normmally.
    There are many  data sources. It all depends what is your reporting requirement or what level of data to be extracted.
    Let me know your reporting requirements to answer further

  • PLSQL code optimizing

    Hi
    My oracle db version is 11g R1/AIX5.3
    how following plsql code can be re-written for better performance
    CREATE OR REPLACE PROCEDURE CSCOMMON.POST_SEQ_PROCESS
    AS
       -- Declare variables to hold sequenced infomration.
       pragma autonomous_transaction;
       V_RECORD_ID           POST_SEQUENCING_PROCESS.RECORD_ID%TYPE;
       V_RECEIVED            POST_SEQUENCING_PROCESS.RECEIVED%TYPE;
       V_PROCESS_NAME        POST_SEQUENCING_PROCESS.PROCESS_NAME%TYPE;
       V_PROCESS_ID          POST_SEQUENCING_PROCESS.PROCESS_ID%TYPE;
       V_PROCESS_SEQ         POST_SEQUENCING_PROCESS.PROCESS_SEQ%TYPE;
       V_RECEIVER            POST_SEQUENCING_PROCESS.RECEIVER%TYPE;
       V_RECEIVER_ID         POST_SEQUENCING_PROCESS.RECEIVER_ID%TYPE;
       V_RECEIVER_SEQ        POST_SEQUENCING_PROCESS.RECEIVER_SEQ%TYPE;
       V_SENDER              POST_SEQUENCING_PROCESS.SENDER%TYPE;
       V_SENDER_ID           POST_SEQUENCING_PROCESS.SENDER_ID%TYPE;
       V_MESSAGE_ID          POST_SEQUENCING_PROCESS.MESSAGE_ID%TYPE;
       V_INSTANCE_ID         POST_SEQUENCING_PROCESS.INSTANCE_ID%TYPE;
       V_STATUS              POST_SEQUENCING_PROCESS.STATUS%TYPE;
       V_STEP_ID             POST_SEQUENCING_PROCESS.STEP_ID%TYPE;
       V_INTERNAL_ID         POST_SEQUENCING_PROCESS.INTERNAL_ID%TYPE;
       V_LOCK_ID             POST_SEQUENCING_PROCESS.LOCK_ID%TYPE;
       V_ERROR_HANDLING      POST_SEQUENCING_PROCESS.ERROR_HANDLING%TYPE;
       V_STARTED             POST_SEQUENCING_PROCESS.STARTED%TYPE;
       V_WARNINGS            POST_SEQUENCING_PROCESS.WARNINGS%TYPE;
       V_DOCUMENTTYPE_NAME   POST_SEQUENCING_PROCESS.DOCUMENTTYPE_NAME%TYPE;
       V_DOCUMENTTYPE_ID     POST_SEQUENCING_PROCESS.DOCUMENTTYPE_ID%TYPE;
       V_DOCUMENTTYPE_SEQ    POST_SEQUENCING_PROCESS.DOCUMENTTYPE_SEQ%TYPE;
       v_current             VARCHAR2 (600);
       v_sql_error           VARCHAR2 (600);
       lv_count              NUMBER;
       CURSOR c_first500
       IS
          SELECT RECORD_ID,
                 RECEIVED,
                 PROCESS_NAME,
                 PROCESS_ID,
                 PROCESS_SEQ,
                 RECEIVER,
                 RECEIVER_ID,
                 RECEIVER_SEQ,
                 SENDER,
                 SENDER_ID,
                 MESSAGE_ID,
                 INSTANCE_ID,
                 STATUS,
                 STEP_ID,
                 INTERNAL_ID,
                 LOCK_ID,
                 ERROR_HANDLING,
                 STARTED,
                 WARNINGS,
                 DOCUMENTTYPE_NAME,
                 DOCUMENTTYPE_ID,
                 DOCUMENTTYPE_SEQ
            FROM (  SELECT RECORD_ID,
                           RECEIVED,
                           PROCESS_NAME,
                           PROCESS_ID,
                           PROCESS_SEQ,
                           RECEIVER,
                           RECEIVER_ID,
                           RECEIVER_SEQ,
                           SENDER,
                           SENDER_ID,
                           MESSAGE_ID,
                           INSTANCE_ID,
                           STATUS,
                           STEP_ID,
                           INTERNAL_ID,
                           LOCK_ID,
                           ERROR_HANDLING,
                           STARTED,
                           WARNINGS,
                           DOCUMENTTYPE_NAME,
                           DOCUMENTTYPE_ID,
                           DOCUMENTTYPE_SEQ
                      FROM CSCOMMON.SEQUENCING_PROCESS
                  ORDER BY RECEIVED)
           WHERE ROWNUM < 101;
       P_RAND                NUMBER;
       V_LID                 NUMBER;
    BEGIN
       v_current := 'BEFORE CURSOR OPENING';
       SELECT COUNT (*) INTO lv_count FROM POST_SEQUENCING_PROCESS;
       OPEN c_first500;          
       LOOP
          SELECT CSCOMMON.SEQ_LID_SEQUENCING_PROCESS_NU.NEXTVAL
            INTO V_LID
            FROM DUAL;
         UPDATE CSCOMMON.SEQUENCING_PROCESS A
             SET A.LOCK_ID = V_LID ,
                 A.STATUS = 1,
                 A.STARTED = SYSDATE,
                 A.WARNINGS = 0
           WHERE NOT EXISTS
                        (SELECT 1
                           FROM CSCOMMON.SEQUENCING_PROCESS B
                          WHERE ( (A.RECEIVER_ID = B.RECEIVER_ID
                                   AND A.RECEIVER_SEQ = 1)
                                 OR (A.PROCESS_ID = B.PROCESS_ID
                                     AND A.PROCESS_SEQ = 1)
                                 OR (A.DOCUMENTTYPE_ID = B.DOCUMENTTYPE_ID
                                     AND A.DOCUMENTTYPE_SEQ = 1))
                                AND (A.ERROR_HANDLING = 0 OR B.STATUS != 4)
                                AND B.RECORD_ID < A.RECORD_ID)
                 AND A.STATUS = 2
                 AND 1024 =
                                        (SELECT WM1.STATUS
                           FROM WMLOG610.WMPROCESS WM1,
                                (  SELECT MAX (AUDITTIMESTAMP) AUDITTIMESTAMP,
                                          INSTANCEID
                                     FROM WMLOG610.WMPROCESS WM2
                                    WHERE INSTANCEID IN
                                             (SELECT INSTANCE_ID
                                                FROM CSCOMMON.SEQUENCING_PROCESS where rownum<101)
                                 GROUP BY INSTANCEID
                                 ORDER BY instanceid) WM2
                          WHERE     A.INSTANCE_ID = WM1.INSTANCEID
                                AND WM1.INSTANCEID = WM2.INSTANCEID
                                AND WM1.AUDITTIMESTAMP = WM2.AUDITTIMESTAMP
                                AND ROWNUM = 1)
                 AND A.LOCK_ID IS NULL
                 AND A.DOCUMENTTYPE_NAME != 'FxHaulage';
    commit;
          FETCH c_first500
          INTO V_RECORD_ID,
               V_RECEIVED,
               V_PROCESS_NAME,
               V_PROCESS_ID,
               V_PROCESS_SEQ,
               V_RECEIVER,
               V_RECEIVER_ID,
               V_RECEIVER_SEQ,
               V_SENDER,
               V_SENDER_ID,
               V_MESSAGE_ID,
               V_INSTANCE_ID,
               V_STATUS,
               V_STEP_ID,
               V_INTERNAL_ID,
               V_LOCK_ID,
               V_ERROR_HANDLING,
               V_STARTED,
               V_WARNINGS,
               V_DOCUMENTTYPE_NAME,
               V_DOCUMENTTYPE_ID,
               V_DOCUMENTTYPE_SEQ;
          EXIT WHEN c_first500%NOTFOUND;
          BEGIN
             v_current := 'INSERT INTO POST_SEQUENCING_PROCESS';
             IF (lv_count = 0)
             THEN
                INSERT INTO POST_SEQUENCING_PROCESS (RECORD_ID,
                                                     RECEIVED,
                                                     PROCESS_NAME,
                                                     PROCESS_ID,
                                                     PROCESS_SEQ,
                                                     RECEIVER,
                                                     RECEIVER_ID,
                                                     RECEIVER_SEQ,
                                                     SENDER,
                                                     SENDER_ID,
                                                     MESSAGE_ID,
                                                     INSTANCE_ID,
                                                     STATUS,
                                                     STEP_ID,
                                                     INTERNAL_ID,
                                                     LOCK_ID,
                                                     ERROR_HANDLING,
                                                     STARTED,
                                                     WARNINGS,
                                                     DOCUMENTTYPE_NAME,
                                                     DOCUMENTTYPE_ID,
                                                     DOCUMENTTYPE_SEQ)
                     SELECT *
                       FROM cscommon.sequencing_process A
                      WHERE lock_id IS NOT NULL
                            AND A.DOCUMENTTYPE_NAME != 'FxHaulage' order by lock_id;
                            commit;
                INSERT INTO CSCOMMON.PRE_SEQUENCING_PROCESS
                   (SELECT * FROM CSCOMMON.POST_SEQUENCING_PROCESS);
    commit;
                DELETE FROM CSCOMMON.POST_SEQUENCING_PROCESS;
                COMMIT;
                v_current := 'DELETE FROM SEQUENCING_PROCESS';
                DELETE FROM CSCOMMON.SEQUENCING_PROCESS
                      WHERE LOCK_ID IS NOT NULL
                            AND DOCUMENTTYPE_NAME != 'FxHaulage';
                COMMIT;
             ELSE
                RETURN;
             END IF;
          END;
       END LOOP;
       CLOSE c_first500;                    
       COMMIT;
    EXCEPTION
       WHEN OTHERS
       THEN
          v_sql_error := SQLERRM || ' - ' || v_current;
          ROLLBACK;
    END;
    /May be by using forall /bulk collections
    Thanks
    Raj

    You need to understand transactional consistency. Not only are your commits
    slowing things down, they are not good for maintaining transactional consistency.
    Ask yourself what would happen if there was a problem in your procedure after
    the first commit? How would you recover from that with some records
    updated but the rest of your procedure not having been run?
    In general you should only have one commit at the topmost level. By that I mean if
    there is a program that kicks of other ones and is the 'master' controller, that
    should be the one that decides to commit or rollback the whole transaction.
    Also you need to understand exception handling. Your exception processing is dangeroulsly wrong.
    Remove it.
    Finally, try and do this processing without using cursor loops: pure (set-based) SQL is much faster than
    slow cursor based PL/SQL and SQL together.

  • Project Lombok - easier getters and setters

    I came across [Project Lombok|http://projectlombok.org/] recently and I think it greatly simplifies common Java patterns. All those getters and setters needed to satisfy JPA, JSF, and CDI make conceptually trivial classes become hundred-line monsters. If you need to change a type (e.g. int to long) or a name, then you need to do the same thing three or more times, or you can delete and generate everything again, but this can be risky: you might delete and regenerate a method that contained some little but necessary extra logic (a null check with ?:, for example), which could be indistinguishable from boilerplate code at first sight.
    I know this will be met with resistance, but I think a Lombok-like project should be incorporated into Java SE 8 or 9. Look at the great productivity improvements we had with Java 5 and Java 7 (specifically Project Coin). Look how easy it is to create an EJB in Java EE 6. People that would never consider EJBs in the past are now using them (me included) and enjoying!
    Maybe Java tools could at least provide official tools to support Lombok, because it currently uses unsupported interfaces to do its work.
    I think this post, if taken as an official feature request, would be off-topic here, but hey, I already have an account here and the conversation must start somewhere :-)

    MarcusF. wrote:
    All those getters and setters needed to satisfy JPA, JSF, and CDI make conceptually trivial classes become hundred-line monsters. Only when you're doing something very wrong design-wise. Getters and setters are no problem, you generate them anyway. But go ahead, keep believing the incredibly trivial is what is keeping you from being productive.
    Look how easy it is to create an EJB in Java EE 6.Yes its easier to CREATE an EJB. But it is still as hard as ever to understand the nuances of the technology and properly apply it without cutting into your own fingers. You still need to properly understand transaction management for example. But also stateless design, remote invocation, messaging, concurrency, etc. etc. Its still very, very hard. But yeah, annotations in stead of XML crud. That made -all- the difference right?
    It isn't code that makes things easier. It never was and it never will be. But people keep focusing on simplifying the actual programming by spitting out API after API and framework after framework and in the mean time the technology never gets any easier, or better. Because the code is not where the problem is.
    IMO of course.

  • UPDATE statement and database locks

    Hello everybody,
    I have a problem related to an UPDATE statement. There are two applications, let say A and B.
    Application A executes:
    update some_table
    set some_field = 'value_A',
    where pk_field=1
    no commit!
    Application B executes:
    update some_table
    set some_field = 'value_B',
    where pk_field=1
    Now application B is locked and wait until application A executes a commit.
    THIS IS A PROBLEM!
    I know one way to solve this problem:
    Both applications should execute "select for update nowait" before
    updating a row.
    Is there any other solutions? Something like "update nowait"?
    thanks in advance
    Dmitri Geller
    DGeller (at) lhsgroup dot com

    The major difference between my approach and standard "select for update nowait + update"
    approach, is more information for user : who blocked his object, and when. Else , i don't see the
    differences. Yep. And a Boieng 747 and bicycle is not much a difference as both are used for transporting people.
    Are you against select + nowait ?No, I am for understanding transaction isolation, serialisation, ACID principles, the differences between optimistic and pessimitic locking and so on
    You wrote "THE LOCK is good". OK, and what about time ?The two has NOTHING to do with one another. Not a single thing.
    In real industrial systems the users cannot wait more then few seconds. But the transactions can
    run much more. It isn't acceptable.If by implication you mean that I'm in the .edu environment that does not deal with "real corporate systems", I'm not.
    I recently wrote a special replicator in PL/SQL. It makes extensive use of customised parallel processing (does not use PQ as it also support Oracle SE). It hits very busy tables (with far over a 1000 rows/sec transaction rate). I did not have to hack my own form of locking. Performance is excellent.
    Why? Not because I am a brilliant Linus-like programming genius. Simply because I used Oracle as it has been designed to use.
    Can you claim the same? Can you show me the Oracle reference material that states that you need to write your own Lock Manager? Can you show me expert opinion from recognised inviduals such as Tom Kyte, Jonathan Lewis, Gary Milsap and others that state that Oracle's concurrency controls need to be hacked like you did in order to make it work?
    Can you provide me with any sound technical evidence to backup your claims that your method is better than what Oracle has built into the core of the database?

Maybe you are looking for