insert problem

I insert e new record in a table (TOracleDataset). The primary key is assigned automatically by a trigger. I would like the end user to be able to see this primary key right after creating a new record (after calling Table1.Insert).

I set RefreshOptions = [roAfterInsert]

If I do

Table1.Insert;
Table1.Post;
Table1.Edit; // Error occur here

I end up with an error (A lock, refresh or check cannot be performed without a rowid.....) but if I assign a value to one of the fields in the table in between, for example

Table1.Insert;
Table1FIRST_NAME.AsString := 'something';
Table1.Post;
Table1.Edit;

it works just the way I want, except for that the first name is set to something.

I'm using the evaluation version of DOA 3.4.4 for Delphi 5.

Btw. I have a registered version of DOA 3.4.1 but I cannot find where to download an update.

//Jonas
 
I'm not exactly sure why you get this specific error message, but you cannot insert an empty record. When you post a new, empty record, it will effectively be cancelled. Maybe you should assign a dummy value to the field that will be modified in the trigger on the server.

A 'cleaner' solution may be to call a stored function that gets the primary key value(s) in the OnNewRecord event handler.

------------------
Marco Kalter
Allround Automations
 
Back
Top