Calling tQuery.Edit after tQuery.Insert

I am working with Delphi 3.0 and MSSQL 6.5.
I have created a table as so:

Create Table InsertUpdateTest
  (Col1  Int  Not Null Primary Key
  ,Col2  VarChar(30) Not Null Default ''
  ,Col3  DateTime Not Null Default GetDate()
  )

wwQuery1.Sql is 'Select * from InsertUpdateTest' and the RequestLive
property is True.

I have the following code:

  Randomize ;
  Database1.StartTransaction ;
  wwQuery1.Insert ;
  wwQuery1.FieldByName('Col1').Value := Random(1000000000) ;
  wwQuery1.FieldByName('Col2').Value := IntToStr(Random(1000000000)) ;
  // wwQuery1.FieldByName('Col3').Value := Now ;
  wwQuery1.Post ;
  wwQuery1.Edit ; // Exception raised if I don't set Col3. No exception if I
do set Col3.
  wwQuery1.FieldByName('Col3').Value := Now ;
  wwQuery1.Post ;
  Database1.Commit ;
  wwQuery1.Close ;
  wwQuery1.Open ;

The dilemma: If I don't set a value for Col3 on the insert, I get exception
EDBEngineError with message

'Couldnt perform the edit because another user changed the record.' when I
call the Edit method.

I am using SQL Trace and I get the following:

(After Post)
INSERT INTO InsertUpdateTest (Col1 ,Col2 )  VALUES (854911742, '138562609')

(After Edit)
SELECT COUNT(*)  FROM InsertUpdateTest WHERE Col1=854911742 AND
Col2='138562609' AND Col3 IS NULL

I have tried changing the UpdateMode from upWhereAll (the default) to
upWhereKeyOnly, and I am not finding it makes a difference. When I call the
edit method, the BDE still generates the same Where clause (which includes
Col3).

I don't know what else I can do, other than comment out the line in
TQuery.Edit that calls CheckOperation.

Any assistance is greatly appreciated! Many, many thanks!

Respond via email or this newsgroup.