Subject | Re: [firebird-support] Insert/Update fields not present in a view |
---|---|
Author | Urs Liska |
Post date | 2005-01-06T11:04:13Z |
Antwort auf Nachricht:
@S@.
@A@ schrieb am @D@
...
AS
select
ID, /* Primary key of PERSON */
BEZ, /* short identifyer for display */
NACHNAME,
VORNAME,
LEBENSDATEN,
NACHNAME_SDX,
VORNAME_SDX
from PERSON
join RDB$DATABASE on 1=1
where SEK_AUTOR_FL = 1;
?
Thank you for the tip, it works well when selecting.
But when I insert a record in the view with a trigger like:
INSERT INTO PERSON (
NACHNAME,
VORNAME,
LEBENSDATEN,
sek_autor_fl) /* BEZ will be set in a trigger of PERSON */
VALUES (
NEW.NACHNAME,
NEW.VORNAME,
NEW.LEBENSDATEN,
1);
I get an error: "The insert failed because a column definition includes
validation constraints.
validation error for column ID, value "*** null ***"."
Of course, the primary key ID is a NOT NULL field, but in the BI-trigger
of PERSON I have the
IF (NEW.ID IS NULL) THEN
NEW.ID = GEN_ID(GEN,1);
clause which should take care of that.
Could you please tell me what am I doing wrong?
Thank you
Urs
@S@.
@A@ schrieb am @D@
> Urs Liska wrote:Something like this:
>
>
>>If it was a joined view I could of course (and would have to) execute
>>insert statements for all tables. It would be no problem to set the flag
>>field then.
>
>
> In this case, the easiest way to solve the problem is to make this a
> joined view by joining with rdb$database.
>
...
AS
select
ID, /* Primary key of PERSON */
BEZ, /* short identifyer for display */
NACHNAME,
VORNAME,
LEBENSDATEN,
NACHNAME_SDX,
VORNAME_SDX
from PERSON
join RDB$DATABASE on 1=1
where SEK_AUTOR_FL = 1;
?
Thank you for the tip, it works well when selecting.
But when I insert a record in the view with a trigger like:
INSERT INTO PERSON (
NACHNAME,
VORNAME,
LEBENSDATEN,
sek_autor_fl) /* BEZ will be set in a trigger of PERSON */
VALUES (
NEW.NACHNAME,
NEW.VORNAME,
NEW.LEBENSDATEN,
1);
I get an error: "The insert failed because a column definition includes
validation constraints.
validation error for column ID, value "*** null ***"."
Of course, the primary key ID is a NOT NULL field, but in the BI-trigger
of PERSON I have the
IF (NEW.ID IS NULL) THEN
NEW.ID = GEN_ID(GEN,1);
clause which should take care of that.
Could you please tell me what am I doing wrong?
Thank you
Urs
> Regards,
>
>
> Ann
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
>