Subject | Re: [IBO] New record in IB_Query |
---|---|
Author | Lucas Franzen |
Post date | 2005-05-18T10:17:15Z |
Vlado,
malyv2 schrieb:
value after posting (just the database knows it). So IBO can't locate
the record since it doesn't know the value.
And you have to assign a value since you have a SELECT * which includes
the pk column (ID_VYK) which is defined NOT NULL.
So IBO doesn't let you post the record without having a value assigned.
You can bypass this by setting the required property of this field
(ID_VYK) in the query editor to FALSE.
But this won't help you with the locate problem.
My advide:
a) Rewrite your trigger that it is ONLY assigning a value when the field
IS NULL
trigger:
IF ( NEW.ID_VYK IS NULL ) THEN NEW.ID_VYK = GEN_ID(GEN_VYK,1);
b) let IBO assign the primary key value by using the GeneratorLinks
proerty of the Query.
Just enter this code in the GeneratorLinks property:
ID_VYK=GEN_VYK
When doing an insert IBO automatically calls the GEN_ID method for the
generator GEN_VYK and is assigning a value to your field ID_VYK.
And: Set the KeyLinks property of your IB_Query to ID_VYK, too (and set
the KeyLinksautoDefine property to FALSE).
You can post, since your primary key is not part of the select
statement, so IBO doesan't know that it is a not nullable /thus
required) field.
And out of the same reason you cannot locate the record since there's no
field in the eselect that will identify this record.
Luc.
malyv2 schrieb:
> I try make simple program.Adding a trigger that's supplying a primary key doesn't tell IBO the
> I use IB_Query, IB_Grid, IB_UpdateBar and IB_NavigationBar like that
> demo in tutorials. I have trigger on before insert - new.ID_VYK =
> GEN_ID(GEN_VYK, 1); In table VYK is ID_vyk primary key.
>
> a) IB_Query with SELECT * FROM VYK
> When I try insert new row and post it, next error raised: "record
> ID_vyk is a required field". I must type anything in ID_vykon, then I
> can post it. In ID_VYK is number that I typed. Then I use "edit row"
> from update bar, change anything and use post. Next error raised:
> "Record was not located to update". I know that it is because trigger
> assigned different ID_vyk than I "must" typed.
value after posting (just the database knows it). So IBO can't locate
the record since it doesn't know the value.
And you have to assign a value since you have a SELECT * which includes
the pk column (ID_VYK) which is defined NOT NULL.
So IBO doesn't let you post the record without having a value assigned.
You can bypass this by setting the required property of this field
(ID_VYK) in the query editor to FALSE.
But this won't help you with the locate problem.
My advide:
a) Rewrite your trigger that it is ONLY assigning a value when the field
IS NULL
trigger:
IF ( NEW.ID_VYK IS NULL ) THEN NEW.ID_VYK = GEN_ID(GEN_VYK,1);
b) let IBO assign the primary key value by using the GeneratorLinks
proerty of the Query.
Just enter this code in the GeneratorLinks property:
ID_VYK=GEN_VYK
When doing an insert IBO automatically calls the GEN_ID method for the
generator GEN_VYK and is assigning a value to your field ID_VYK.
And: Set the KeyLinks property of your IB_Query to ID_VYK, too (and set
the KeyLinksautoDefine property to FALSE).
> b) IB_Query with SELECT CODE, NAME FROM VYKSame as above:
> I can insert and post new row without error. But when I try edit the
> new row I get the same error - "Record was not located to update"
You can post, since your primary key is not part of the select
statement, so IBO doesan't know that it is a not nullable /thus
required) field.
And out of the same reason you cannot locate the record since there's no
field in the eselect that will identify this record.
Luc.