Fetch Autonumber from Firebird ?
-
i am developing a project with VB6 and Firebird 2.1.3. When i update the table tblPartyMaster and examines the adoRsParty!PartyID which is a primary key,autoincrement, unique identifier returns 0 (Zero) instead of New PartyID Value which i need for further processing.
With adoRsParty
.AddNew
!CompanyName="Sample Company"
.Update
msgbox !PartyID
End WithI have create a Generator for PartyID and a Before Insert Trigger on table tblpartyMaster as
CREATE TRIGGER TR_AI_TBLPARTYMASTER_PARTYID FOR TBLPARTYMASTER
ACTIVE BEFORE INSERT
POSITION 0
AS
BEGIN
NEW.PARTYID = GEN_ID(GEN_TBLPARTYMASTER_PARTYID, 1);
ENDPlease Suggest me some ideas for fetching the PrimaryKey (PartyID) Value of newly inserted row. Expecting some advice or ideas or guidance With regards K.Senthil Babu
-
i am developing a project with VB6 and Firebird 2.1.3. When i update the table tblPartyMaster and examines the adoRsParty!PartyID which is a primary key,autoincrement, unique identifier returns 0 (Zero) instead of New PartyID Value which i need for further processing.
With adoRsParty
.AddNew
!CompanyName="Sample Company"
.Update
msgbox !PartyID
End WithI have create a Generator for PartyID and a Before Insert Trigger on table tblpartyMaster as
CREATE TRIGGER TR_AI_TBLPARTYMASTER_PARTYID FOR TBLPARTYMASTER
ACTIVE BEFORE INSERT
POSITION 0
AS
BEGIN
NEW.PARTYID = GEN_ID(GEN_TBLPARTYMASTER_PARTYID, 1);
ENDPlease Suggest me some ideas for fetching the PrimaryKey (PartyID) Value of newly inserted row. Expecting some advice or ideas or guidance With regards K.Senthil Babu
You can use a storedprocedure, I think trigger is not convenient. Just use an Output parama in your code. If you face any problem please let me know.
Thanks Md. Marufuzzaman
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
-
You can use a storedprocedure, I think trigger is not convenient. Just use an Output parama in your code. If you face any problem please let me know.
Thanks Md. Marufuzzaman
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
From my Delphi and Interbase days I remember that the methodology the OP is using (before insert trigger and GEN_ID) is the recommended way of doing things. Unfortunately I have never tried to access Interbase/FireBird from VB and therefore am unable to help.
Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”
-
You can use a storedprocedure, I think trigger is not convenient. Just use an Output parama in your code. If you face any problem please let me know.
Thanks Md. Marufuzzaman
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
Thanks Md. Marufuzzaman, I Created a procedure instead of Trigger along with the generator and called the procedure from the front end for autonumber, it works fine. Thanks A Lot.
-
Thanks Md. Marufuzzaman, I Created a procedure instead of Trigger along with the generator and called the procedure from the front end for autonumber, it works fine. Thanks A Lot.
You are most welcome.. :)
Thanks Md. Marufuzzaman
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.