Subject | Re: [firebird-support] Execute Block: Need Insert Into to trigger Primary Key generator. |
---|---|
Author | Mark Rotteveel |
Post date | 2018-02-27T08:29:33Z |
On 27-2-2018 03:17, homer@... [firebird-support] wrote:
vulnerabilities (some of which are fixed in newer 2.1.x versions, some
of which require you to upgrade to 2.5 or newer). The latest 2.1.x is
2.1.7. Given 2.1.x was discontinued in 2014, you really should be
looking at upgrading to a newer version
inserted with a null primary key (which isn't even possible).
You should not specify the PK_ID column, Firebird currently has no
`DEFAULT` clause for inserts (and if it existed, it would only work like
you want with an identity column)
INSERT INTO ACORD_DATA (FK_ID, D_ACORD_FORM_FIELD_NAME,
D_ACORD_FORM_FIELD_TYPE, STR_VALUE) VALUES (972, 'FrmCmplDtA', 'CHAR',
'02/26/2018')
The insert shown in your second message should work, if it doesn't, you
need to show us your trigger code, and be more precise in your problem
description: neither statements can lead to null primary keys, as
primary keys cannot be null.
Mark
--
Mark Rotteveel
> Firebird 2.14, Delphi 2007, Multi-User App, IBDac components.Why are you using 2.1.4? Version 2.1.4 has known security
vulnerabilities (some of which are fixed in newer 2.1.x versions, some
of which require you to upgrade to 2.5 or newer). The latest 2.1.x is
2.1.7. Given 2.1.x was discontinued in 2014, you really should be
looking at upgrading to a newer version
> I need to insert many multiple rows ( 200 to 600) in a single event. ToThis wouldn't work and should lead to a token unknown error, not in rows
> avoid network slowing the process, I'm trying Execute Block for the
> first time (just learned about it). The code below doesn't work because
> the Primary Key is null. There is a generator but this doesn't seem to
> trigger it. Any help will be greatly appreciated.
>
>
> SQL snippet:
> set term ^ ;
>
> EXECUTE BLOCK AS BEGIN
>
> INSERT INTO ACORD_DATA (PK_ID, FK_ID, D_ACORD_FORM_FIELD_NAME,
> D_ACORD_FORM_FIELD_TYPE, STR_VALUE) VALUES (Default ,972, 'FrmCmplDtA',
> 'CHAR', '02/26/2018');
>
> INSERT INTO ACORD_DATA (PK_ID, FK_ID, D_ACORD_FORM_FIELD_NAME,
> D_ACORD_FORM_FIELD_TYPE, STR_VALUE) VALUES (Default ,972, 'ProFullNmA',
> 'CHAR', 'Waterman Insurance Agency Inc.');
>
> INSERT INTO ACORD_DATA (PK_ID, FK_ID, D_ACORD_FORM_FIELD_NAME,
> D_ACORD_FORM_FIELD_TYPE, STR_VALUE) VALUES (Default ,972,
> 'ProAuthReprSigA', 'CHAR', '');
>
> INSERT INTO ACORD_DATA (PK_ID, FK_ID, D_ACORD_FORM_FIELD_NAME,
> D_ACORD_FORM_FIELD_TYPE, STR_VALUE) VALUES (Default ,972, 'FrmEdIdA',
> 'CHAR', '');
>
> END^
>
> set term ; ^
inserted with a null primary key (which isn't even possible).
You should not specify the PK_ID column, Firebird currently has no
`DEFAULT` clause for inserts (and if it existed, it would only work like
you want with an identity column)
INSERT INTO ACORD_DATA (FK_ID, D_ACORD_FORM_FIELD_NAME,
D_ACORD_FORM_FIELD_TYPE, STR_VALUE) VALUES (972, 'FrmCmplDtA', 'CHAR',
'02/26/2018')
The insert shown in your second message should work, if it doesn't, you
need to show us your trigger code, and be more precise in your problem
description: neither statements can lead to null primary keys, as
primary keys cannot be null.
Mark
--
Mark Rotteveel