Nested Transaction and J2EE
Hi,
I have a question about how J2EE Application server (WAS4.x/5.x) follows the spec for Nested transaction. In a J2EE tutorial at one place it says
http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/Transaction4.html
following :
A JTA transaction is controlled by the J2EE transaction manager. You may want to use a JTA transaction because it can span updates to multiple databases from different vendors. A particular DBMS's transaction manager may not work with heterogeneous databases. However, the J2EE transaction manager does have one limitation--it does not support nested transactions. In other words, it cannot start a transaction for an instance until the previous transaction has ended.
It means I cannot start another transaction while the first one is not completed.
CASE 1:
My statefull session bean has method a() and method b().
Method a() calls Method b().
I have started userTransaction in Method a() and before commiting
it I have started another transaction in method b(). like
Method a() {
Statrs TX
calls b()
Commits TX
Method b() {
Starts TX
Commits TX
CASE 2:
What if I use Declarative TX
and specify method a() requires new
and method b() also requires new.
Where, method b() is invoked by method a() in a statefull session
bean.
Thanks in advance.
I had i similar problem and solved it in th following way.
My first attempt was to call an atomic method which has the transaction attribute "RequiresNew" from a complex method with the transaction attribute "Required". Both methods where located in the same Session EJB class. If the code inside the atomic method fails by an exception, the exception will be catched and ctx.setRollbackOnly( ) be called in the catch block. This does NOT work! So I start reading a lot in the net and in books. I foud that J2EE does not support nested transactions. So that was a shoot in my foot! :-(
Frustated I went home from work and in the evening I remember some words from Adam Bien, the author of J2EE Patterns. He said that you can build something like nested transactions if you use an additional EJB layer. He said that in the context of a SessionFacade and a set of EntityBeans. But he also said that this will also work with layers of SessionBeans.
At the next day, I build the addional Session EJB and moved all atomic methods in that Session EJB. So the situation is now like this. My ComplexEJB holds method which define a more complex business process. Each of this processes call a lot of atomic methods from the Atomic EJB. In my case it�s not neccesary that all of this atomic methods have to succeed. OK, the methods with transaction attribute "Required" will proceed as much atomic methods with transaction attribute "RequiresNew" as possible! But if a "hard" Exception occurs the whole transaction is rolled back.
This works very good for our needs!
public class ComplexEJB implements SessionBean
public Collection complexMethod1( Parameter param ) throws BusinessException
try
service = this.getAtomicServiceLocal( );
service.atomicMethod1( param.getSubparam1( ) );
service.atomicMethod3( param.getSubparam3( ) );
service.atomicMethod1( param.getSubparamN( ) );
service.atomicMethod1( param.getSubparam1( ) );
catch( "hard" exception like Nullpointer i.e. )
//if an "hard" Exception occur rollback the whole transaction
ctx.setRollbackOnly( );
public Collection complexMethodN( Parameter param ) throws BusinessException
try
service = this.getAtomicServiceLocal( );
service.atomicMethod1( param.getSubparam1( ) );
service.atomicMethod3( param.getSubparam3( ) );
service.atomicMethod1( param.getSubparamN( ) );
service.atomicMethod1( param.getSubparam1( ) );
catch( "" hard exception like Nullpointer i.e. )
//if an "hard" Exception occur rollback the whole transaction
ctx.setRollbackOnly( );
public class AtomicEJB implements SessionBean
public Collection atomicMethod1( Parameter param ) throws BusinessAtomicException
try
//The call to a service i.e. access to database
catch ( DatabseException cbex )
ctx.setRollbackOnly( );
finally
//release database connection i.e.
public Collection atomicMethodN( Parameter param ) throws BusinessAtomicException
try
//The call to a service i.e. access to database
catch ( DatabseException cbex )
ctx.setRollbackOnly( );
finally
//release database connection i.e.
Similar Messages
-
Query related with nested transaction
Friends,
Today i've been encountered with problem in running a nested transaction and i guess the sample script given below illustrates well abt the same ...
I've a proc "sp_proc1" as follows
CREATE OR REPLACE PROCEDURE sp_proc1
AS
val INT;
BEGIN
val := 1;
BEGIN SAVEPOINT proc1;
INSERT INTO tab1 VALUES ( 1 , 2 );
sp_proc2(val);
ROLLBACK TO SAVEPOINT proc1;
END;
and the called proc is like this
CREATE OR REPLACE PROCEDURE sp_proc2
val1 IN INT DEFAULT NULL
AS
BEGIN SAVEPOINT proc2;
UPDATE tab1 SET col1 = 5;
IF val1 = 0 THEN
BEGIN
ROLLBACK TO SAVEPOINT proc2;
END;
ELSE
BEGIN
COMMIT;
END;
END IF;
END;
and when i exec the proc1
ORA-01086: savepoint 'PROC1' never established
Any suggestions on this .....Autonomous transactions are independent units of work and should be completely
committed of rolled back before returning from an autonomous program unit.
So anything you do in the calling procedure doesn't affect the autonomous one:
SQL> create table t (id number);
Table created.
SQL> create or replace procedure auto_01
2 is
3 pragma autonomous_transaction;
4 begin
5 insert into t values(1);
6 savepoint a;
7 insert into t values(2);
8 rollback to savepoint a;
9 commit;
10 end;
11 /
Procedure created.
SQL> begin
2 insert into t values(3);
3 savepoint a;
4 auto_01;
5 insert into t values(4);
6 rollback to savepoint a;
7 commit;
8 end;
9 /
PL/SQL procedure successfully completed.
SQL> select * from t;
ID
3
1Rgds. -
Nested Transactions are not supported by J2EE.
I am a relative newbie to J2EE and am trying to get my head around transactions. I will use the following components to illustrate my questions.
I have two container managed enterprise beans, Bean-1 and Bean-2. Bean-1 has a single method method-A. Bean-2 also has a single method method-B. The code in method-A calls method-B.
We have the following scenarios:
1. A servelet calls method-A, starting a new transaction. Method-A calls method-B.
2. Another servlet calls method-B starting a new transaction.
And now for my first questions ......
Am I right in saying that, as the beans are container managed, scenario 1 does not create a nested transaction as the begin and commit are controlled by the container and only issued at the beginning / end of the overall transaction as appropriate.
Now lets change the set-up slightly. Lets assume that both beans have bean managed transactions using JTA. At the beginning and end of both method calls appropriate begin / commit / abort code is inserted.
And now the second question ......
A call to method-B starting a new transaction (scenario 2) works fine. Am I right in saying that a call to method-A under scenario 1 would not be allowed as when method-A calls method-B a nested transaction would occur as both methods have begin / commit code.
Thanks any help with this query.
Paulhello
We have a very strange problem in our application.
I have the following code in an MDB onMessage() metod
// inserts 100 rows into table1
//in the dploymentdescriptor method is marked with requiednew
statelessSessionBean1.generaterowsWithNewTransaction();
//updates a row in table2
//in the dploymentdescriptor method is marked with requiednew
statelessSessionBean2.updaterow1WithNewTransaction();
//updates a row in table3
//in the dploymentdescriptor method is marked with requiednew
statelessSessionBean3.updaterow2WithNewTransaction();
when the above code is successfully executed and transactions are
committed succussfully, we have at times the situation like the first
100 lines inserted into DB are not available but the other two table
rows are updated. After a while if we see again in DB we are finding
the 100 rows as well. Again this situation happens very sporadically.
Any help would be appreciated. Thanks in advance.
Venkat -
Database connectivity toolset and nested transaction
Is it possible to make nested transactions with the Database Connectivity Toolset ?
By nested transactions I mean that I want to open a transaction inside a transaction.
I use LabVIEW 6.1 and Database Connectivity Toolset 1.1
Any ideas are welcome.You may be able to do this in a different manner. Your options depend on how the database has structured the data. For example you can have a table defining "measures", another table defining "measure setps" and so on.
Each measure has an ID (MID) and each measure step has an ID (MSID) and these can be related to each other to provide the hierarchy. So in this case you could just get a measure, then query for all the measure steps that match (the MID and MSID) and sort them based on some attribute/criteria and work down in that manner.
This would provide a clean data architecture and enable you to reuse steps in multiple measures if you needed to. I'm not sure how your database is building the hierarchy, in the end there are some parent ch
ild relationships defined ... these would be very similar to the IDs referred to above.
Like you said, had to explain without a picture.
Regards,
Kamran -
Nested Transaction required... workaround?
We have a situation that would best be coded with a nested transaction. As J2EE does not support these, are there standard ways to work around this sort of problem? Our situation is:
1. Get a msg from JMS
2. Process the message- involves inserting data into multiple tables...
- If successful- commit msg from queue; commit data.
- If unsuccessful- move msg to error queue; rollback ALL table inserts.
Our current proposed workaround involves around 4 sequential transactions, use of staging tables, etc. etc. I feel there ought to be a cleaner solution.
Ideas most welcome...
Gavin Griffith-JonesHi Gavin,
You can do the following:
- If you are not using an EJB, then start a transaction using the Java Transaction API (JTA).
- When obtaining a connection to the database for the inserts, use a transactional datasource.
- Start the transaction within a try/catch block and perform the inserts sequentially. If an exception is thrown, rollback the transaction with the UserTransaction rollback method. This will rollback all the insertions.
- If no exceptions were thrown, then call the tran.commit() method in the try/catch block.
Since there is a lot to do, contain your code in different classes for a cleaner solution.
Best of luck,
Rich -
Distributed transactions and 2-phase commit in a SAP Netweaver environment
Hello,
I am a Java architect., I don't know very much the SAP technologies. I tried to found on forums or technical papers if SAP does support distributed transactions and two-phase commit, it's not clear. I found something on SAP WAS but my project is using a SAP PI 7.0 and I cannot find anything on the subject.
My goal is to include a SAP server (via PI 7.0) in a distributed transaction handled by a J2EE ESB (Oracle, ex-BEA Aqualogic) based on XA capabilities.
Does anyone have experience or feedback on this topic ?
Thanks.Hi,
Do you know this white paper ?
[Distributed Transaction and 2 phase commit|https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/3732d690-0201-0010-a993-b92aab79701f]
Regards,
Olivier -
Renew License Problem - Option NSP and J2E (7.0) Windows Not Available
Hi all,
I Download and instaled the :
- SAP NetWeaver 7.0 Java Trial Version - SP14SR3
- SAP NetWeaver 7.0 ABAP Trial Version - SP12
for Windows almost 90 days ago.
To Renew the license I went to link "SAP Sneak Preview License Key Request"
[https://websmp130.sap-ag.de/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/minisap/minisap.htm]
But at "System Id *" combobox the correspondent options for Windows intalations above are not available (J2EE and NSP).
Pls, how to proceed ? I remember I did it with older versions (< SP14/SP12) with no problem.
Best Regards and thanks for your help.>
Klaus Keller wrote:
> see my posting at SAP NetWeaver Application Server
>
> Rgds,
> Klaus
Hi Mr. Klaus Keller, first at all, thanks a lot for your help,
After your msg I requested the license renew for NSP and J2EE with success, but when I tried to instal the new license file NSP.txt (User=SAP* / Transaction=SLICENSE) I received the error msg:
"Error when installing permanent license key - This system's system number is "000000000310714511", but there is a license key for system number "000000000310994500" in the license key file."
In fact the System Number on SLICENSE transaction and NSP.txt are diferents.
Looking at installation documentation (start.html / Getting Started) it shows the screen to request the renew license and it has the option below wich is not available at actual screen:
System number [ _________________ ] (For prologation only)
I tried to change the System Number manually at NSP.txt but the license becames invalid.
I did not try with J2E.txt license cause I notice that the System Number is different too.
Thanks for your attention,
Walmir Catunda.
PS. As the thread [No longer able to renew licenses for SAP Netweaver 2004 Linux Testdrive?|No longer able to renew licenses for SAP Netweaver 2004 Linux Testdrive?; is closed (answered) I will keep this and put a note to this one -
JTA Transaction and CUrrent Session
We have the following problem. We configured hibernate with
jta and when we execute a simple code that performs some hibernate
queries we get the following error:
"org.hibernate.LazyInitializationException: could not
initialize proxy - the owning Session was closed"
We discovered that if we leave the session opened the error
disapears, but on the long run this crashes the server throwing a
JDBC connection error.
We tried to use getCurrentSession() instead of opening the
session manualy but in this case we get the following error:
"org.hibernate.HibernateException : Unable to locate current
UserTransaction"
This its quite strange because the current session should be
bound to the current user transaction and its seems to us that our
hibernate cfg file its ok.
I´am posting part of my hibernate cfg file and the code
that I execute.
hibernate.cfg.xml
<hibernate-configuration>
<session-factory name="java:/hibernate/SessionFactory">
<property
name="hibernate.connection.datasource">java:fiap</property>
<property
name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
<!-- Enable Hibernate's automatic session context
management -->
<property
name="hibernate.current_session_context_class">jta</property>
<property
name="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactor y</property>
<property
name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.JBossTransact ionManagerLookup</property>
<property
name="jta.UserTransaction">java:comp/UserTransaction</property>
<!-- <property
name="connection.release_mode">after_statement</property>
-->
<!-- <property
name="hibernate.transaction.flush_before_completion">true</property>-->
<property
name="hibernate.transaction.auto_close_session">true</property>
and my java Code:
try {
tx = HUtil.getTx(); //JNDI lookup
tx.begin();
session = HUtil.getSessionFactory().getCurrentSession();
//JNDI Lookup
//session = HUtil.getSessionFactory().openSession();
Query query = session.createQuery("from Persona where
username = ?");
query.setString(0, userName);
persona = (Persona) query.uniqueResult();
query = session.createQuery("from Festival where id = ?");
query.setInteger(0, idFestival);
festival = (Festival) query.uniqueResult();
if (persona != null && festival != null) {
query = session.createQuery("from Inscripcion where
inscribeA = :persona " +
"AND inscriptosEn = :festival");
query.setParameter("persona", persona);
query.setParameter("festival", festival);
inscripcion = (Inscripcion) query.uniqueResult();
return inscripcion;
} catch (Exception e) {
e.printStackTrace();
throw e;
} finally {
tx.commit();
//session.close();
thanksThe scenario you described is typical ... "If a client calls m1" ... there are 2 cases:
(1) the client is already in a trans
(2) not (1)
Let (1). This is the case of a Client Controlled Transaction ... etc ... when s1 is called it begins a transaction in the client transactional context ... hence s1 can't call a kind of roolback but can force the rollback of the global transaction marking EJBContext.setRollbackOnly() ... s2 uses the same transactional context ... anayway the client is the only one that can commit. This happens because of "transaction required" as the transaction attribute, that in this case forces a flat transaction model. Different is the case if you uses "requiredNew" --> nested trans model ...
(2) is the same of (1) except that the trans starts at application tier.
"I still have one doubt. Wouldn't the stateless session bean loose the transaction context once I exit the second stateles session bean's method? Isn't that what stateless means? "
No:
stateless doesn't stay for the transaction context but for the conversational state with the client ... that is serializable ... it makes the beans more poolable ... that the stateful session bean has
bye -
EJB nested transaction handling.
My situation closely relates to the round-trip planning problem. I have a series of say 5 EJBs (session and entity both involved) doing a particular work. If an error occurs at the EJB 5 stage, I don't want to rollback the work done in EJB 1 and 2 but I want EJB 3 onwards to rollback. Is this kind of nested transaction model possible. Please note that I want to use container-managed-transactions. If not possible, please guide me how can I use bean-managed-transaction to solve it? Thanks in advance for any help.
Yes, it is possible, but you have to make sure that ANY call to EJB 3 through that method has the same requirements:
EJB 1 - Transaction = Required
EJB 2 - Transaction = Required
EJB 3 - Transaction = Requires New (starts a new transaction, "holds" the one from 1 & 2)
EJB 4 - Transaction = Requires
EJB 5 - Transaction = Requires -
Dependent transaction and exceptions
Hi,
We have a main transaction with a sub-transaction
(dependent). The main transaction has an exception-
handler that responds to specific exceptions and
communicates to the user why the transaction failed.
However, all exceptions that occur within the depen-
dent transaction are only visible as "AbortTransaction"
exceptions and not as the original exceptions that
caused the transaction to abort.
Is there is way to find the original exception?
Pascal Rottier
STP - MSS Support & Coordination Group
Philip Morris Europe
e-mail: [email protected]
Phone: +49 (0)89-72472530
+++++++++++++++++++++++++++++++++++
Origin IT-services
Desktop Business Solutions Rotterdam
e-mail: [email protected]
Phone: +31 (0)10-2428100
+++++++++++++++++++++++++++++++++++
/* Ever stop to think, and forget to start again? */
To unsubscribe, email '[email protected]' with
'unsubscribe forte-users' as the body of the message.
Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/forte>Hello,
When you have nested transactions in forte and when the call within the nested
transaction
fails, forte should raise an AbortException , but what forte raises is an
internal (private) implementation of AbortException called qqsp_AbortException.
And if the calls are made to the database the exception is qqdb_AbortException, I
believe. If you are still particular in handling the exceptions out of nested
transactions, you could trap the exception by coding for this type..
Exception
when e: qqsp_abortException do
This code compiles and works. You might have a problem down the road if forte
changes the name of this exception or removes it totally.
In any case, the calls made from the outer transaction are not committed until
all the inner transaction calls are committed. So if any call in the inner
transaction fails the calls made from the outer transaction are also rolled back.
If you wish to commit the calls made in the outer transaction, you would have to
handle the exception raised from the inner transaction. Since forte does not
raise the abort exception correctly, you would have to code for
qqsp_abortexception or move away from nested transactions.
Good luck,
Bala Cuddalore
Sage IT Partners
Rottier, Pascal wrote:
Hi,
We have a main transaction with a sub-transaction
(dependent). The main transaction has an exception-
handler that responds to specific exceptions and
communicates to the user why the transaction failed.
However, all exceptions that occur within the depen-
dent transaction are only visible as "AbortTransaction"
exceptions and not as the original exceptions that
caused the transaction to abort.
Is there is way to find the original exception?
Pascal Rottier
STP - MSS Support & Coordination Group
Philip Morris Europe
e-mail: [email protected]
Phone: +49 (0)89-72472530
+++++++++++++++++++++++++++++++++++
Origin IT-services
Desktop Business Solutions Rotterdam
e-mail: [email protected]
Phone: +31 (0)10-2428100
+++++++++++++++++++++++++++++++++++
/* Ever stop to think, and forget to start again? */
To unsubscribe, email '[email protected]' with
'unsubscribe forte-users' as the body of the message.
Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/forte>-
To unsubscribe, email '[email protected]' with
'unsubscribe forte-users' as the body of the message.
Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/forte> -
Nested UnitOfWork and reading newly created objects...
Hi, my understanding is that when using nested UnitOfWork the transactions are not committed to the database until the outer most UnitOfWork is committed.
If a new object is created in a nested UnitOfWork and then a attempt is made to read that object in an outer (or other nested) UnitOfWork (so that it can be used as the parent of another new object) that object is not found because the overall UnitOfWork has not been committed yet.
Is there a way to accomplish this? i.e. access objects that may already exist or have been newly created within a nested UnitOfWork.
Thanks for any help and ideas.
-Tim WatsonHi Don, yes this works as you describe above ... except we have a little wrinkle in our application regarding instance level access control. If i disable access control checking then the objects are retrieved correctly. But when we have access control enabled the newly created objects are not found. Here's an example of the processing;
1. Create the new object ObjA, in this example ObjA will be a Folder object in the UOW.
2. Create a new Authorization Lookup object that gives permission to the current user to acccess ObjA in the same UOW.
3. Later in the process flow, another object is created in the same UOW, ObjB, that will be a child of ObjA, so we need to lookup ObjA. In our application to do access control we append to the query, via the Expression, additional criteria like this;
"select ... from ... where .... and (t1.ID = t2.ID) and (t2.user_id = 'user') and (bitand(t2.privilege, 2) = 2) and ..."
(t1 being the domain object table and t2 the authorization lookup table)
so when we have this access control added to the query then it can't find the new, and uncommitted objects, but if not using this then it works fine.
Any ideas about this? i know all these objects are registered in the same UOW.
Thanks,
-Tim Watson -
What is difference between enjoy transactions and Normal transactions
What is difference between enjoy transactions and Normal transactions
Ex:- ME22 & ME22N
What is difference between these two.hi ,
the transaction code with 'N' are created with help of object concept.
In your case ME22 is obsolete one and ME22N is the tcode created with object concept.
pls Reward helpful points
Thanks
Siva -
Open AR transaction and Receipts
Can you let me know the standard concurrent programs which list all the Receivables Open AR Transaction and Open AR Receipts
The table ar_payment_Schedules_all gives you the outstanding information as on date. For eg. if the system date is 13th April and if you query the ar_payment_schedules_all table, the amount_due_remaining column will give you the open amount as on that date.
However if you want the oustanding as on some previous date, lets say as on 31st March, in that case you have to rollback all the applications that would have occured from 1st april to 13th april.
Find below the script that I used to get the oustanding as on any previous date. Pls. note that I am using a temp table here to populate the details.
declare
v_cash_receipt NUMBER;
v_adjustment NUMBER;
v_credit_memo NUMBER;
v_as_of_outstanding NUMBER;
v_cash_receipt_acctd NUMBER;
v_adjustment_acctd NUMBER;
v_credit_memo_acctd NUMBER;
v_credit_memo_acctd_1 NUMBER;
v_as_of_outstanding_acctd NUMBER;
p_as_of_date DATE;
cursor cs_get_trx (p_as_of_date1 IN Date) is
SELECT ps.customer_id CUST_ACCOUNT_ID
, trx.creation_date INV_CREATION_DATE
, ps.trx_number INVOICE_NUMBER
, trx.trx_date INVOICE_DATE
, ps.gl_date GL_DATE
, NVL(ps.amount_due_original,0) INVOICE_AMOUNT
, NVL(ps.tax_original,0) TAX_AMOUNT
, NVL(ps.acctd_amount_due_remaining,0) ACCTD_OUTSTANDING_AMOUNT
, ps.due_date
, CEIL(sysdate - ps.due_date) DAYS_OUTSTANDING
, ps.payment_schedule_id
, ps.number_of_due_dates INSTALLMENT_NUMBER
, trx.customer_trx_id
, CEIL(p_as_of_date1 - ps.due_date) DAYS_LATE_AS_OF
FROM ra_customer_trx TRX
, ar_payment_schedules PS
WHERE
trx.customer_trx_id = ps.customer_trx_id
AND ps.gl_date <= p_as_of_date1
AND ps.gl_date_closed > p_as_of_date1 ;
CURSOR cs_get_receipt(p_as_of_date2 IN DATE ) IS
SELECT ps.customer_id CUST_ACCOUNT_ID
, ps.payment_schedule_id
, CEIL(p_as_of_date - ps.GL_DATE) days_late_as_of_r
, ps.gl_date
, cr.receipt_number
, app.cash_receipt_id
, sum(app.acctd_amount_applied_from) ACCTD_AMOUNT_APPLIED
FROM ar_receivable_applications app
, ar_cash_receipts cr
, ar_payment_schedules ps
WHERE app.cash_receipt_id = cr.cash_receipt_id
AND app.payment_schedule_id = ps.payment_schedule_id
AND app.status in ('ACC', 'UNAPP', 'UNID', 'OTHER ACC' )
AND NVL(app.confirmed_flag,'Y') = 'Y'
AND app.gl_date <= p_as_of_date2
AND ps.gl_date <= p_as_of_date2
AND ps.gl_date_closed > p_as_of_date2
AND ( ( app.reversal_gl_date IS NOT NULL AND ps.gl_date <= p_as_of_date2 )
OR app.reversal_gl_date IS NULL
GROUP BY ps.customer_id
, cr.receipt_number
, app.cash_receipt_id
, ps.payment_schedule_id
, ps.gl_date
HAVING
sum(app.acctd_amount_applied_from) <> 0 ;
Begin
delete zxc_aging_cust1 ;
p_as_of_date := to_date('&Enter_as_of_date','DD-MON-RRRR') ;
For invoice in cs_get_trx(p_as_of_date)
LOOP
/* cash applied after p_as_of_date */
SELECT NVL(SUM(NVL(acctd_amount_applied_to, 0.0) +
NVL(acctd_earned_discount_taken,0.0) +
NVL(acctd_unearned_discount_taken,0.0)),0.0)
INTO v_cash_receipt_acctd
FROM ar_receivable_applications
WHERE TRUNC(gl_date) > p_as_of_date
AND status||'' = 'APP'
AND NVL(confirmed_flag,'Y') = 'Y'
AND applied_payment_schedule_id = invoice.payment_schedule_id
AND application_type LIKE 'CASH%';
/* adjustments applied after p_as_of_date */
SELECT NVL(SUM(ar_adjustments.acctd_amount), 0.0)
INTO v_adjustment_acctd
FROM ar_adjustments
WHERE TRUNC(gl_date) > p_as_of_date
AND status = 'A'
AND payment_schedule_id = invoice.payment_schedule_id;
/* invoice credited after p_as_of_date */
SELECT nvl(sum(nvl(acctd_amount_applied_to, 0.0)), 0.0)
INTO v_credit_memo_acctd
FROM ar_receivable_applications
WHERE applied_payment_schedule_id = invoice.payment_schedule_id
AND nvl(confirmed_flag,'Y') = 'Y'
AND status||'' = 'APP'
AND TRUNC(gl_date) > p_as_of_date
AND application_type LIKE 'CM%';
/*added new by anil patil 7/7/7 */
/* credit memo applied after p_as_of_date */
SELECT nvl(sum(nvl(acctd_amount_applied_to, 0.0)), 0.0)
INTO v_credit_memo_acctd_1
FROM ar_receivable_applications
WHERE payment_schedule_id = invoice.payment_schedule_id
AND nvl(confirmed_flag,'Y') = 'Y'
AND status||'' = 'APP'
AND TRUNC(gl_date) > p_as_of_date
AND application_type LIKE 'CM%';
/* calculate actual outstanding amount */
v_as_of_outstanding_acctd := invoice.acctd_outstanding_amount + v_cash_receipt_acctd - v_adjustment_acctd +
v_credit_memo_acctd - v_credit_memo_acctd_1 ;
insert into zxc_aging_cust1
( customer_id ,
invoice_number ,
invoice_date ,
gl_date ,
invoice_amount ,
tax_amount ,
acctd_outstanding_amount ,
due_date ,
days_outstanding ,
installment_number ,
days_late_as_of ,
current_os_amt ,
cash_receipt_amt ,
adj_amt ,
credit_memo_amt ,
credit_memo_amt_1
values
(invoice.cust_account_id ,
invoice.invoice_number ,
invoice.invoice_date ,
invoice.gl_date ,
invoice.invoice_amount ,
invoice.tax_amount ,
v_as_of_outstanding_acctd ,
invoice.due_date ,
invoice.days_outstanding ,
invoice.installment_number ,
invoice.days_late_as_of ,
invoice.acctd_outstanding_amount ,
v_cash_receipt_acctd ,
v_adjustment_acctd ,
v_credit_memo_acctd ,
v_credit_memo_acctd_1
END LOOP ;
COMMIT;
FOR receipt in cs_get_receipt (p_as_of_date )
LOOP
INSERT INTO zxc_aging_cust1( customer_id
, invoice_number
, trx_type
, acctd_outstanding_amount
, gl_date
VALUES( receipt.cust_account_id
, receipt.receipt_number
, 'RECEIPT'
, -1 * receipt.acctd_amount_applied
, receipt.gl_date );
END LOOP;
COMMIT ;
END;
Hope this helps.
Thanks,
Anil -
Material Transaction and Move Transaction Managers are Going Inactive
hi
it was running previously but currently it becomes inactive.can any one tell in which table to look for the error related to this problem?
Kind Regards
SayantanHi;
What is your OS and EBS?
It was working before? If yes what have you been changed on your system(patch etc)
Please check below note:
Material Transaction And Move Transaction Managers Are Going Inactive [ID 93507.1]
Material Transaction and Move Transaction Managers are Going Inactive [ID 98757.1]
Regard
Helios -
Re: Transactions and Locking Rows for Update
Dale,
Sounds like you either need an "optimistic locking" scheme, usually
implemented with timestamps at the database level, or a concurrency manager.
A concurrency manager registers objects that may be of interest to multiple
users in a central location. It takes care of notifying interested parties
(i.e., clients,) of changes made to those objects, using a "notifier" pattern.
The optimistic locking scheme is relatively easy to implement at the
database level, but introduces several problems. One problem is that the
first person to save their changes "wins" - every one else has to discard
their changes. Also, you now have business policy effectively embedded in
the database.
The concurrency manager is much more flexible, and keeps the policy where
it probably belongs. However, it is more complex, and there are some
implications to performance when you get to the multiple-thousand-user
range because of its event-based nature.
Another pattern of lock management that has been implemented is a
"key-based" lock manager that does not use events, and may be more
effective at managing this type of concurrency for large numbers of users.
There are too many details to go into here, but I may be able to give you
more ideas in a separate note, if you want.
Don
At 04:48 PM 6/5/97 PDT, Dale "V." Georg wrote:
I have a problem in the application I am currently working on, which it
seems to me should be easily solvable via appropriate use of transactions
and database locking, but I'm having trouble figuring out exactly how to
do it. The database we are using is Oracle 7.2.
The scenario is as follows: We have a window where the user picks an
object from a dropdown list. Some of the object's attributes are then
displayed in that window, and the user then has the option of editing
those attributes, and at some point hitting the equivalent of a 'save'button
to write the changes back to the database. So far, so good. Now
introduce a second user. If user #1 and user #2 both happen to pull up
the same object and start making changes to it, user #1 could write back
to the database and then 15 seconds later user #2 could write back to the
database, completely overlaying user #1's changes without ever knowing
they had happened. This is not good, particularly for our application
where editing the object causes it to progress from one state to the next,
and multiple users trying to edit it at the same time spells disaster.
The first thing that came to mind was to do a select with intent to update,
i.e. 'select * from table where key = 'somevalue' with update'. This way
the next user to try to select from the table using the same key would not
be able to get it. This would prevent multiple users from being able to
pull the same object up on their screens at the same time. Unfortunately,
I can think of a number of problems with this approach.
For one thing, the lock is only held for the duration of the transaction, so
I would have to open a Forte transaction, do the select with intent to
update, let the user modify the object, then when they saved it back again
end the transaction. Since a window is driven by the event loop I can't
think of any way to start a transaction, let the user interact with the
window, then end the transaction, short of closing and re-opening the
window. This would imply having a separate window specifically for
updating the object, and then wrapping the whole of that window's event
loop in a transaction. This would be a different interface than we wanted
to present to the users, but it might still work if not for the next issue.
The second problem is that we are using a pooled DBSession approach
to connecting to the database. There is a single Oracle login account
which none of the users know the password to, and thus the users
simply share DBSession resources. If one user starts a transaction
and does a select with intent to update on one DBSession, then another
user starts a transaction and tries to do the same thing on the same
DBSession, then the second user will get an error out of Oracle because
there's already an open transaction on that DBSession.
At this point, I am still tossing ideas around in my head, but after
speaking with our Oracle/Forte admin here, we came to the conclusion
that somebody must have had to address these issues before, so I
thought I'd toss it out and see what came back.
Thanks in advance for any ideas!
Dale V. Georg
Indus Consultancy Services [email protected]
Mack Trucks, Inc. [email protected]
>
>
>
>
====================================
Don Nelson
Senior Consultant
Forte Software, Inc.
Denver, CO
Corporate voice mail: 510-986-3810
aka: [email protected]
====================================
"I think nighttime is dark so you can imagine your fears with less
distraction." - CalvinWe have taken an optimistic data locking approach. Retrieved values are
stored as initial values; changes are stored seperately. During update, key
value(s) or the entire retieved set is used in a where criteria to validate
that the data set is still in the initial state. This allows good decoupling
of the data access layer. However, optimistic locking allows multiple users
to access the same data set at the same time, but then only one can save
changes, the rest would get an error message that the data had changed. We
haven't had any need to use a pessimistic lock.
Pessimistic locking usually involves some form of open session or DBMS level
lock, which we haven't implemented for performance reasons. If we do find the
need for a pessimistic lock, we will probably use cached data sets that are
checked first, and returned as read-only if already in the cache.
-DFR
Dale V. Georg <[email protected]> on 06/05/97 03:25:02 PM
To: Forte User Group <[email protected]> @ INTERNET
cc: Richards* Debbie <[email protected]> @ INTERNET, Gardner*
Steve <[email protected]> @ INTERNET
Subject: Transactions and Locking Rows for Update
I have a problem in the application I am currently working on, which it
seems to me should be easily solvable via appropriate use of transactions
and database locking, but I'm having trouble figuring out exactly how to
do it. The database we are using is Oracle 7.2.
The scenario is as follows: We have a window where the user picks an
object from a dropdown list. Some of the object's attributes are then
displayed in that window, and the user then has the option of editing
those attributes, and at some point hitting the equivalent of a 'save' button
to write the changes back to the database. So far, so good. Now
introduce a second user. If user #1 and user #2 both happen to pull up
the same object and start making changes to it, user #1 could write back
to the database and then 15 seconds later user #2 could write back to the
database, completely overlaying user #1's changes without ever knowing
they had happened. This is not good, particularly for our application
where editing the object causes it to progress from one state to the next,
and multiple users trying to edit it at the same time spells disaster.
The first thing that came to mind was to do a select with intent to update,
i.e. 'select * from table where key = 'somevalue' with update'. This way
the next user to try to select from the table using the same key would not
be able to get it. This would prevent multiple users from being able to
pull the same object up on their screens at the same time. Unfortunately,
I can think of a number of problems with this approach.
For one thing, the lock is only held for the duration of the transaction, so
I would have to open a Forte transaction, do the select with intent to
update, let the user modify the object, then when they saved it back again
end the transaction. Since a window is driven by the event loop I can't
think of any way to start a transaction, let the user interact with the
window, then end the transaction, short of closing and re-opening the
window. This would imply having a separate window specifically for
updating the object, and then wrapping the whole of that window's event
loop in a transaction. This would be a different interface than we wanted
to present to the users, but it might still work if not for the next issue.
The second problem is that we are using a pooled DBSession approach
to connecting to the database. There is a single Oracle login account
which none of the users know the password to, and thus the users
simply share DBSession resources. If one user starts a transaction
and does a select with intent to update on one DBSession, then another
user starts a transaction and tries to do the same thing on the same
DBSession, then the second user will get an error out of Oracle because
there's already an open transaction on that DBSession.
At this point, I am still tossing ideas around in my head, but after
speaking with our Oracle/Forte admin here, we came to the conclusion
that somebody must have had to address these issues before, so I
thought I'd toss it out and see what came back.
Thanks in advance for
any
ideas!
Dale V. Georg
Indus Consultancy Services [email protected]
Mack Trucks, Inc. [email protected]
------ Message Header Follows ------
Received: from pebble.Sagesoln.com by notes.bsginc.com
(PostalUnion/SMTP(tm) v2.1.9c for Windows NT(tm))
id AA-1997Jun05.162418.1771.334203; Thu, 05 Jun 1997 16:24:19 -0500
Received: (from sync@localhost) by pebble.Sagesoln.com (8.6.10/8.6.9) id
NAA11825 for forte-users-outgoing; Thu, 5 Jun 1997 13:47:58 -0700
Received: (from uucp@localhost) by pebble.Sagesoln.com (8.6.10/8.6.9) id
NAA11819 for <[email protected]>; Thu, 5 Jun 1997 13:47:56 -0700
Received: from unknown(207.159.84.4) by pebble.sagesoln.com via smap (V1.3)
id sma011817; Thu Jun 5 13:47:43 1997
Received: from tes0001.macktrucks.com by relay.macktrucks.com
via smtpd (for pebble.sagesoln.com [206.80.24.108]) with SMTP; 5 Jun
1997 19:35:31 UT
Received: from dale by tes0001.macktrucks.com (SMI-8.6/SMI-SVR4)
id QAA04637; Thu, 5 Jun 1997 16:45:51 -0400
Message-ID: <[email protected]>
Priority: Normal
To: Forte User Group <[email protected]>
Cc: "Richards," Debbie <[email protected]>,
"Gardner," Steve <[email protected]>
MIME-Version: 1.0
From: Dale "V." Georg <[email protected]>
Subject: Transactions and Locking Rows for Update
Date: Thu, 05 Jun 97 16:48:37 PDT
Content-Type: text/plain; charset=US-ASCII; X-MAPIextension=".TXT"
Content-Transfer-Encoding: quoted-printable
Sender: [email protected]
Precedence: bulk
Reply-To: Dale "V." Georg <[email protected]>
Maybe you are looking for
-
How to add a JMenubar and a JTable in a JFrame in a single application
Hi all, I require an urgent help from you.I am a beginer in programming Swing.I want to add a menu,combobox,and a table in a single application.I did coding as below: package com.BSS; import java.awt.*; import java.awt.event.*; import javax.swing.*;
-
Tricky query needing clever SQL...
A table called alt_websearch_log records the time it takes to complete each search performed on a website. I am therefore able to write something like this: select to_char(search_date,'DD/MON/YYYY'), count(*), avg(searchtime_secs), max(searchtime_sec
-
Select performance from all_tables vs user_tables (same for columns)
Hi, I need to run two queries, one is to select either all tables of a specific owner, the other query is to select all columns of that owner. Sometimes the owner is the user I connected as, and sometimes its different. I was wondering what the perfo
-
Capturing screen layout ?
Hello, I want to create a drawing program that allows users to compose text, images and simple drawn shapes. Once the user has created their artwork, I want to send it back to my database so I can get it printed. What is the best strategy for doing t
-
On a Windows platform. I recently installed CS6 and everything appeared to be working fine. I was able to open older CS5.5 docs without any issues. I decided to delete the entire CS5.5 Suite and now I find whenever I go to open any of these old CS5.5