Subject RE: [IBO] TIBOQuery insert with parameters
Author Jason Wharton
> I have a simple query as below which has a PK "LOC_ID" and a mandatory
> field "PVERSION_ID" which is an FK.
>
> SELECT
> LOC_ID,
> PVERSION_ID,
> NAME
> FROM LOC
> WHERE PVERSION_ID = :var_PVERSION_ID
>
> I need the value for :var_PVERSION_ID to be automatically put into
> PVERSION_ID during an insert. Here is the insert code:
>
> INSERT INTO LOC(
> LOC_ID, /*PK*/
> PVERSION_ID,
> NAME)
> VALUES (
> :LOC_ID,
> :PVERSION_ID,
> :NAME)
>
> Should this work OK when I test it by manually preparing it, then
> entering a parameter, opening the returned records in the TIBO
> component and inserting a row manually?
>
> I thought I had this working before, but now it doesn't seem to. Can't
> figure out why. I keep getting an error that PVERSION_ID must have a
> value.
>
> Any help would be appreciated.

Where you have the input variable with the "var_" prefix there is no way
that IBO would automatically assume what you are wanting it to.

I suggest you use the OnNewRecord event to plug in the value that you want.

MyField_PVERSION_ID.AsString := MyParam_var_PVERSION_ID.AsString;


HTH,
Jason Wharton