Interbase Triggers

Hi,

Looking at Triggers again. Run into similar problem from years ago (Delphi 6'ish). Currently using Interbase 2017 Dev edition with Rad Studio 10.2.3.

Want a unique primary key (eg IDno), with a trigger. When make a new record (client side), want it automatically to generate a new IDno type of thing server side.

Problem:

- Primary Keys require not NULL, so it throws an error before can activate the trigger;

Any suggestions to get around this?

What used to do, was slap a 0 or negative against the IDno client side, and changed the trigger to <1 check before insert. Then the new record is given a new IDno, but also need to refresh so have the new IDno client side. If have multiple users using system, can use like their UserID as negative value, then should avoid any chance of clash of unique even if tries to process several new records at same instance.

But this seams messy to me, so presume is a better way. 

Other approach thought of would to be pass all the field values from client side, asking server to make new record (insert) server side, where the trigger should activate and work? Still need to refresh client side. Its also a lot bulkier on the code and harder to maintain. 

Any ideas? 

Thanks.

Parents Reply Children
No Data