Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: interbase auto increment fields problem



Permlink Replies: 3 - Last Post: Jul 24, 2017 2:44 AM Last Post By: Dmitry Arefiev
Liste Listeler

Posts: 49
Registered: 7/26/07
interbase auto increment fields problem
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 21, 2017 3:21 PM
Hi,
I am porting my db from Sqlite to IbLite
I have some problems.
Normaly if I define auto increment fields in sqlite Firedac can Understand that and add ServerAutoinc options.
But In interbase it is not working.
Noww I have a error Field Id must have value in interbase.
But it should add by generator and transaction.

Is there any example about that
Which is the best settings for auto increment fields for firedac and interbase

my interbase table is
CREATE TABLE TEST (
TEST_ID DOM_INTEGER NOT NULL,
ID DOM_INTEGER DEFAULT NULL,
"NAME" DOM_TWIDEMEMOFIELD,
SHORTNAME DOM_TWIDEMEMOFIELD,
VARIABLES DOM_TWIDEMEMOFIELD,
BPSENUM DOM_INTEGER);

ALTER TABLE TEST ADD PRIMARY KEY (TEST_ID) USING INDEX RDB$PRIMARY31;

SET TERM ^ ;

CREATE TRIGGER BI_TEST_TEST_ID FOR TEST
ACTIVE BEFORE
INSERT
POSITION 0
AS
BEGIN
IF (NEW.TEST_ID IS NULL) THEN
NEW.TEST_ID = GEN_ID(TEST_TEST_ID_GEN, 1);
END^

SET TERM ; ^

Diego Rodrigues...

Posts: 11
Registered: 8/19/17
Re: interbase auto increment fields problem
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 21, 2017 3:47 PM   in response to: Liste Listeler in response to: Liste Listeler
Liste Listeler wrote:
Normaly if I define auto increment fields in sqlite Firedac can Understand that and add ServerAutoinc options.
But In interbase it is not working.
Noww I have a error Field Id must have value in interbase.
But it should add by generator and transaction.

What are the ServerAutoinc options you mention?
Ahmet Nuri DENİZ

Posts: 23
Registered: 6/26/13
Re: interbase auto increment fields problem
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 22, 2017 7:49 AM   in response to: Liste Listeler in response to: Liste Listeler
Hi
Your table is good.

In the Firedac Query has 2 option for that

UpdateOptions-> AutoIncFields
Select your Id field
and
select generator from
UpdateOptions ->
GeneratorName

Liste Listeler wrote:
Hi,
I am porting my db from Sqlite to IbLite
I have some problems.
Normaly if I define auto increment fields in sqlite Firedac can Understand that and add ServerAutoinc options.
But In interbase it is not working.
Noww I have a error Field Id must have value in interbase.
But it should add by generator and transaction.

Is there any example about that
Which is the best settings for auto increment fields for firedac and interbase

my interbase table is
CREATE TABLE TEST (
TEST_ID DOM_INTEGER NOT NULL,
ID DOM_INTEGER DEFAULT NULL,
"NAME" DOM_TWIDEMEMOFIELD,
SHORTNAME DOM_TWIDEMEMOFIELD,
VARIABLES DOM_TWIDEMEMOFIELD,
BPSENUM DOM_INTEGER);

ALTER TABLE TEST ADD PRIMARY KEY (TEST_ID) USING INDEX RDB$PRIMARY31;

SET TERM ^ ;

CREATE TRIGGER BI_TEST_TEST_ID FOR TEST
ACTIVE BEFORE
INSERT
POSITION 0
AS
BEGIN
IF (NEW.TEST_ID IS NULL) THEN
NEW.TEST_ID = GEN_ID(TEST_TEST_ID_GEN, 1);
END^

SET TERM ; ^

Dmitry Arefiev

Posts: 1,406
Registered: 12/7/03
Re: interbase auto increment fields problem
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 24, 2017 2:44 AM   in response to: Liste Listeler in response to: Liste Listeler
TEST_ID DOM_INTEGER NOT NULL,

FireDAC will recognize this field as auto-incremental when you will add ExtendedMetadata=True to your connection parameters.

--
With best regards,
Dmitry

Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02