Subject Re: TIBOTable.Insert then Edit
Author kgdonn
I haven't seen a response to this. Let me ask a simpler question.
Is it possible to succesfully carry out the sequence Insert, Post,
Edit (same record), Post with a TIBOTable?

Thanks,
Kevin Donn

--- In IBObjects@yahoogroups.com, "kgdonn" <kd.ibo@M...> wrote:
>
> It seems either I or IBO is missing something fundamentally
> important. I'm doing an Insert, Post, Edit, & Post on a
TIBOTable,
> and I get "Record was not located to update". What gives?
>
> Here's the code:
>
> procedure TForm1.InsEditBtnClick(Sender: TObject);
> begin
> with TIBOTable.Create(nil) do try
> TableName:='LEA';
> IB_Connection:=IBODatabase1;
> Open;
> Insert;
> Fields[0].AsInteger:=5000;
> Post;
> Edit;
> Fields[1].AsString:='Donn';
> Post
> finally Free end
> end;
>
> And here's the table metadata:
>
>
> /* Table: LEA, Owner: MSEDD */
>
> CREATE TABLE LEA
> (
> LEASEQ INTEGER,
> DISPLAYCODE VARCHAR(10),
> DISTRICTNAME VARCHAR(50),
> COUNTYSEQ INTEGER,
> EDCOOPSEQ INTEGER,
> ESLCOORDINATOR VARCHAR(40),
> ESLPHONE VARCHAR(20),
> ESLEMAIL VARCHAR(50)
> );
>
> /* Index definitions for LEA */
>
> CREATE UNIQUE INDEX LEA_ ON LEA(LEASEQ);
> CREATE INDEX LEA_DISTRICTNAMEINDEX ON LEA(DISTRICTNAME);
> SET TERM ^ ;
>
>
> /* Triggers only will work for SQL triggers */
>
> CREATE TRIGGER INIT_LEASEQ FOR LEA
> ACTIVE BEFORE INSERT POSITION 0
> AS BEGIN
> IF (NEW.LEASeq IS NULL) THEN
> NEW.LEASeq = GEN_ID(Gen_LEASeq, 1);
> END
> ^
>
> COMMIT WORK ^
> SET TERM ;^
>