Hi there!
I got the point where it was causing error. However, when I use the manual
insertion technique with more than one data objects, it is not working.
I am to insert in two different tables, and only after insertion in two is
completed, I want it to be committed, otherwise rolledback.
I associate first data object and set the values for insertion. It is then
executed and if succeeded, it executes another data object after setting
values for it. The data object is then executed. However, this second data
object is not being executed successfully.
I am using the following sort of code : the data objects are doMNameInsert
and doMMasterInsert
CSpInsert doMNInsert = (CSpInsert)CSpider.getDataObject("doMNameInsert");
CSpInsert doMMInsert =
(CSpInsert)CSpider.getDataObject("doMMasterInsert");
tr = new CSpTransaction();
try
if(tr.begin("dsMData"))
{
tr.execute(doMNInsert);
if(tr.succeeded())
doMNInsert.setValue(0,value0);
doMNInsert.setValue(1,value1);
doMNInsert.setValue(2,value2);
tr.execute(doMNInsert);
if(tr.succeeded())
tr.execute(doMMInsert);
if(tr.succeeded())
doMMInsert.setValue(0,value0);
doMMInsert.setValue(1,value1);
doMMInsert.setValue(2,value2);
doMMInsert.setValue(3,value3);
doMMInsert.setValue(4,value4);
doMMInsert.setValue(5,value5);
doMMInsert.setValue(6,value6);
doMMInsert.setValue(7,value7);
tr.execute(doMMInsert);
}
}
}
}
}
catch(Exception e)
{
}
finally
{
if((tr != null) && (tr.isActive()))
if(tr.succeeded())
{
tr.commit();
spider.CSpider.putUserSessionObject("message",new CSpString("Database
Opeartion is Successful"));
load("pgMInfo");
return (SKIP);
}
else
{
tr.rollback();
spider.CSpider.putUserSessionObject("message",new CSpString("Database
Operation RolledBack...Try Again!!!"));
load("pgMInfo");
return (SKIP);
}
}
}
The system is flashing the following software message :
spider.database.CSpTransaction.begin(CSpDateSource): Called when database
transaction is still 'active'. The current active one is automatically
'rolledback'
>From the ND docs, it says : If a previous transaction was active, it is
automatically rolled back and a warning is logged. The method will still
proceed and try to begin a new transaction.
However, there is no previous transaction being executed on this
datasource/dataobjects at that moment.
Please guide me how to correct it.
Thanx.
Rajneesh
----- Original Message -----
From: Aby Mathew <[EMAIL PROTECTED]>
To: 'Rajneesh Garg' <[EMAIL PROTECTED]>;
<[EMAIL PROTECTED]>
Sent: Thursday, January 06, 2000 12:37 AM
Subject: Re: [ND] Insertion Query and CSpValues
> Rajneesh,
>
> On a quick look, I can't find anything wrong with your approach.
>
> Looking at the error (NullPonterException) I think the potential candidate
> in your brief code is a typo in the DataObject name in this line:
> CSpInsert mnInsert = (CSpInsert)CSpider.getDataObject("doMNInsert");
>
> Aby
> TeamND
>
>
> -----Original Message-----
> From: Rajneesh Garg [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, January 05, 2000 2:17 AM
> To: [EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>
> Subject: [ND] Insertion Query and CSpValues
>
>
> Hi there!
>
> I am working on this project on ND5 with Oracle 8i as database. As a part
of
> work, I am required to insert user-input values into the database. These
> values are to be inserted into different tables.
> I am using semi-automatic mode of ND transaction for this purpose. As far
as
> my knowledge of ND API goes, it requires a CSpValue variable for the
value.
> However, the work requires calculation of a field value (a alphanumeric
> string). I am not been able to convert this String value into CSpValue.
> e.g.
> We are asking the user user-name and password. Thus, we can have these in
> CSpValue. However, while inserting into the table, we are giving it a
unique
> alphanumeric code, which we calculate while inserting.
> We are using the code similar to following :
>
> CSpInsert mnInsert = (CSpInsert)CSpider.getDataObject("doMNInsert");
>
> mnInsert.setValue(0,NameFieldValue);
> mnInsert.setValue(1,PasswordValue);
> mnInsert.setValue(2,"CalculatedValue"); file://Problem probably lies
here
>
> CSpTransaction tr = new CSpTransaction();
>
> tr.addDataObject(mnInsert);
>
> int command = tr.execute();
>
> if(tr.succeeded() && (command != STOP_PROCESSING))
> {
> CSpHtml.write("Operation Successful...");
> }
>
> Upon compilation and running of project, when button is clicked, it throws
> exception, saying :
>
>
> * Unexpected exception from an event (java.lang.NullPointerException).
> This is when invoking method btInsert2_onWebEvent for event
> spider.event.CSpWebEvent[ON_WEB_EVENT,
> Method=Project.pgTest.btInsert2_onWebEvent (btInsert2)] on
> spider.visual.CSpButton:
>
> *
> spider.event.adapters.CSpPageEventAdapter.relayGenericEventProcessing:
> Unexpected Exception (java.lang.NullPointerException) caught. Top of
stack:
> |java.lang.NullPointerException
>
>
>
> Please help me out.
> Is my approach right?
>
> Thanx.
> Rajneesh
>
> _________________________________________________________________________
>
> For help in using, subscribing, and unsubscribing to the discussion
> forums, please go to: http://www.netdynamics.com/support/visitdevfor.html
>
> For dire need help, email: [EMAIL PROTECTED]
_________________________________________________________________________
For help in using, subscribing, and unsubscribing to the discussion
forums, please go to: http://www.netdynamics.com/support/visitdevfor.html
For dire need help, email: [EMAIL PROTECTED]