Additional
dbCAP
AnyDAC
ThinDAC
NCOCI8
Topic: Cached Updates problem
Cached Updates problem
Posted: 2002/06/03 10:03
 
In my programs, I'm using Cached Updates with NCOCI, and I created a function that returns the last number +1 of a table. But if I insert two or more records consecutively, I will get the same number.
There is a way to do a query read the data in cache of another query.
RE: Cached Updates problem
Posted: 2002/06/04 02:22
 
The answer is - NO.
Do not use Max()+1 method. It is bad style and leads to very big problems is multi-user databases.
Try using Oracle sequence instead.
BTW NCOCI has TOCISequence component.
If you want to use Sequence to fill the autoincrement field, use DefaultExpression for it:
MyQuery.FieldByName('ID').DefaultExpression := 'MY_SEQUENCE.NextVal()';
This way you don't need TOCISequence component. Assign DefaultExpression in DesignTime or in RunTime BEFORE calling Prepare or Open methods


RE: Cached Updates problem
Posted: 2002/06/04 02:26
 
Correction to previous post. The correct value to assign to DefaultExpression is: NextVal('MY_SEQUENCE')