Subject Re: [IBO] how to use TIBOTable?
Author Helen Borrie
At 07:14 AM 15/05/2011, you wrote:
>Hi - I am converting from a BDE paradox world, where you can use a TTable to insert a new row into a table, and easily retrieve the autogenerated primary key.
>
>If there is a table "mytable" with a autoinc primary key field called "mytableID", it would be easy to insert a new row into the table, and afterwards know the mytableID of the row. Just like this:
>
>
>with TTable.Create(nil) do
>try
> DatabaseName := 'mydb';
> Tablename := 'mytable';
> Open;
> Insert;
> FieldsByName('myfield').AsString := 'this is a new record';
> Post;
> ID := FieldsByName('mytableID').AsInteger;
>finally
> Free
>end;
>
>If I try to do the same thing with TIBOTable towards a firebird DB, the returned value ID is zero.
>
>How do I do this? How do I know what ID the trigger gave the new record.

Read the help text for GeneratorLinks!

Also - plan to drop the TIBOTables when you clean up your migrated application and learn the mysteries of SQL. TIBOTable is transitional - it exists only for compatibility with the Paradox model you are finally abandoning, to ease the migration from the BDE.

Helen