Board index » jbuilder » QueryDataSet saveChanges() exception

QueryDataSet saveChanges() exception


2003-11-21 07:28:21 AM
jbuilder3
I have noticed the following behavior of the QueryDataSet class.
I have two QDS (QueryDataSet) classes Publication and Product. They have
master-detailed relationship. Publication may have multiple products. I can
create Master Record (Publication) and save the record to the Database with
no problme.
Saving the Product Record to the database turned out a bit tricky. I am
getting the following exception:
Borland qds Error: An error occurred adding a row to the
"PCH_SYS"."PCH_PRODUCT" table
Oracle Error: ORA-01400: cannot insert NULL into
("PCH_SYS"."PCH_PRODUCT"."PUB_ID")
Before I call qds_Product.saveChanges() I check whether all neccessary
values are present including the PUB_ID value which is the Foriegn Key in
the Product table. I am also checking that PUB_ID value in my
qds_Publication is the same as in my qds_Producat.
Here is the sample of my code:
public boolean saveProduct(){
boolean result = false;
try {
qds_Product.post(); //This will pushes the value to the queryDataSet
qds_Product.saveChanges(); //This will call
Database.saveChanges(queryDataSet) method
qds_Product.refresh();
//if no exceptins thrown set result to true
result = true;
}
catch (DataSetException dse) {
System.err.println("Borland qds Error: "+dse.getMessage());
System.err.println("Oracle Error:
"+dse.getExceptionChain().getOriginalMessage(dse));
}
return result;
}
Can anybody advise me what is my problem?
Regards,
Alex
Alex G. Terehoff
Booz | Allen | Hamiltion
tel: (301) 4271758
 
 

Re:QueryDataSet saveChanges() exception

In <3fbd4e17$ XXXX@XXXXX.COM >Alex Terehoff wrote:
Quote
I have noticed the following behavior of the QueryDataSet class.

I have two QDS (QueryDataSet) classes Publication and Product. They
have master-detailed relationship. Publication may have multiple
products. I can create Master Record (Publication) and save the record
to the Database with no problme.

Saving the Product Record to the database turned out a bit tricky. I
am getting the following exception:
Generally when you have a master/detail relationship you should use
(psuedo code...)
Database.savechanges(new DataSet[] {masterqds, detailqds})
You will find more details on this in the tutorials on "Resolving
master-detail data sets...."
Have you tried it this way..???
John.
--
=============================================
TeamB are volunteer helpers. Please DO NOT REPLY VIA EMAIL!
Post all questions and replies to this newsgroup ONLY
For papers on DataExpress, Applets, JSP, and Web Development go to:
www.microps.com/mps/papers.html
====================================================