ORA-01400 when apply updates

nboodram

Member²
Hello,

I have a parent-child-grandchild setup using TOracleDatasets on the back end and TClientDatasets on the client end. If I have just parent and child, my updates work fine. When I add the grandchild, the update on the child table loses its primary key field in the "insert" statement and causes an ORA-01400 error.

Is there something that I'm missing that I need to set when doing this? The UpdateMode on the provider is upWhereKeyOnly. The ProviderFlags for the missing field are [pfInUpdate,pfInWhere,pfInKey].

My sample application client code looks like the following, where cdsExpenseGroups is the parent, cdsExpenses is the child and cdsExpenseDetails is the grandchild:

cdsExpenseGroups.Open;
cdsExpenses.Open;
cdsExpenseDetails.Open;

cdsExpenses.Append;
cdsExpensesEXPENSE_ID.Value := 27043;
cdsExpensesEXPENSE_GROUP_ID.Value := 13089;
cdsExpensesEXPENSE_DATE.Value := Date;
cdsExpensesENTRY_DATE.Value := Date;
cdsExpensesMODIFIED_DATE.Value := Now;
cdsExpensesCURRENCY_TYPE.Value := 108;
cdsExpensesCURRENCY_RATE.Value := 1;
cdsExpensesCOUNTRY_ID.Value := 1;
cdsExpenses.Post;

cdsExpenseDetails.Append;
cdsExpenseDetailsEXPENSE_DETAIL_ID.Value := 22648;
cdsExpenseDetailsEXPENSE_ID.Value := 27043;
cdsExpenseDetailsEXPENSE_TYPE_ID.Value := 133;
cdsExpenseDetailsAMOUNT.Value := 123.21;
cdsExpenseDetailsMODIFIED_DATE.Value := now;
cdsExpenseDetails.Post;

cdsExpenseGroups.Post;

cdsExpenseGroups.ApplyUpdates(0);

The following is from the OracleMonitor:
insert into "SIRS_EXPENSES"
("EXPENSE_GROUP_ID", "EXPENSE_DATE", "ENTRY_DATE", "MODIFIED_DATE", "CURRENCY_TYPE", "CURRENCY_RATE", "COUNTRY_ID", "STATE_ABBREVIATION", "CITY_ID", "FOREIGN_CITY")
values
(:V0, :V1, :V2, :V3, :V4, :V5, :V6, :V7, :V8, :V9)

Note the expense_id field is missing.

The sql on the TOracleDataset for the child dataset is
select * from sirs_expenses where expense_group_id = :expense_group_id

Thanks,
Natalie
 
Further information: If the client datasets start off with no parent records and the parent is appended and then the child appended, the error does not happen. If the parent has at least one record and a new parent is appended and then the child appended, the error happens. Hopefully that helps to narrow it down.

Natalie
 
Natalie,

I am using, while I cannot find what is wrong, a trick.
Set your Provider propertie Resolvetodataset to true and try again.
I think that can be work.

Paulo Sergio
 
I tried that when I saw your post and it does not work for me. I get an error on the TOracleDataset "Cannot perform this operation on a closed dataset."

We would not want to use ResolveToDataset as a permanent solution, either, because of the extra overhead.

Natalie
 
Back
Top