Hi,
i use a sequence for this and a trigger, that ensures that the sequence is used, no matter what user input comes from QGIS;

trigger function:

CREATE FUNCTION shema.table_ensure_sequence()
    RETURNS trigger
AS $BODY$
DECLARE
    str_execute text;
BEGIN
    IF (TG_OP = 'INSERT') THEN
        NEW.id := nextval('schema.table_id_seq'); -- use sequence
    ELSIF (TG_OP = 'UPDATE') THEN
        NEW.id := OLD.id; -- do not allow user changes in id
    END IF;
    RETURN NEW;
END;
$BODY$;

Bernhard


Am 13.09.2021 um 08:27 schrieb Alexander Klemm - km3 teledienst GmbH:
Hello,

we want to use QGIS to document our cable Infrastructure (We are an ISP). Now the Problem is, that 3 or 4 persons have to work with QGIS. Now my Idea was to provide a Postgresql Server with postgis installed. Thats working fine. The Project and the Layers are stored into the Postgresql Server and all Persons could work with it. Now my Problem is, that the Contents of the Layers must have an unique ID. The ID is set by the default value at the attribute form with/"maximum($id)+1"/. If two persons are working on the QGIS System, the Problem is, that there are duplicated IDs, because the IDs will not be stored immediately. Is there a solution for this problem?

thank you for helping
best regards

Alexander Klemm

Mit freundlichen Grüßen
Alexander Klemm


km3 teledienst GmbH - August-Bebel-Str. 86 - 08344 Grünhain-Beierfeld
Tel. +49 (0)3774 13931-0 - Fax +49 (0)3774 13931-02
[email protected] - https://www.km3.de
Geschäftsführer: Heiko Lötzsch und Mike Bielagk
Registergericht: Amtsgericht Chemnitz - Handelsregister: B Nr. 18881
Umsatzsteuer-ID: DE 216 086 551 - Steuer-Nr.: 218 / 112 / 02921



__________ Information from ESET Mail Security, version of virus signature database 23952 (20210913) __________

The message was checked by ESET Mail Security.
http://www.eset.com <http://www.eset.com>

_______________________________________________
Qgis-user mailing list
[email protected]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user




__________ Information from ESET Mail Security, version of virus signature 
database 23952 (20210913) __________

The message was checked by ESET Mail Security.
http://www.eset.com





__________ Information from ESET Mail Security, version of virus signature 
database 23952 (20210913) __________

The message was checked by ESET Mail Security.
http://www.eset.com


_______________________________________________
Qgis-user mailing list
[email protected]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user

Reply via email to