Subject Re: [IBO] (unknown)
Author Dmitry Beloshistov
Hello, dark_wolf1812!
You wrote to <IBObjects@yahoogroups.com> on Fri, 30 Apr 2004 12:06:37 -0000:

dw> Sorry for the question again, but I didn't find a solution.

dw> I have 2 tables in the form. One of them is RequestLive:= False, and
dw> the other is RequestLive:= True.
dw> One of them, so, is for edition. When I change to the next register,
dw> the edition table change too, with a routine in the datachange:

dw> procedure TFrmCadPosicao.DsQryTabelaDataChange(Sender:
dw> TIB_StatementLink;
[Sorry, skipped]

dw> end;


dw> When I put in edition, and save, it's ok, but when i'm inserting
dw> data, the problem appears. "The field xxxx (key) is required".

CheckRequired := False

dw> But I generate a number that is to be inserted in the pkfield.
dw> Look:

dw> procedure TFrmCadPosicao.SbGravarClick(Sender: TObject);

[Sorry, skipped]


dw> if RecordCount > 0 then begin
dw> Last;
dw> Chave:= IntToStr(StrToInt(FieldByName(sCampoPK).AsString)
dw> + 1);

Please use generator instead this code!
Chave:=IntToStr(YourIBConnection.Gen_ID('NeedGeneratorName',1));
Hmm... And why Chave variable is string?

dw> end else
dw> Chave:= '1';

[Sorry, skipped]


dw> My Stored Procedure of insertion:

dw> CREATE PROCEDURE INS_POSICAO (

[Sorry, skipped]


May be better :
TB001_CODIGO_POSICAO=GEN_ID('TB001_CODIGO_POSICAO_GEN',1); ?
Put it into BEFORE INSERT trigger or in your stored procedure. In this way
PK value will be
generated automatically on server side - most safe when your client-side PK
generation.


WBR, Dmitry Beloshistov AKA [-=BDS=-]