Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [trigger]

in this context implies a SQL trigger, (aka database trigger), which is a type of stored procedure that is called automatically in response to a specified event in the database.

0
votes
0answers
13 views

PostgreSQL trigger to update fields in table [closed]

I have a table called Calendar with the following fields: [id] [int] NOT NULL, [calendar_date] [date] NOT NULL, [calendar_year] [int] NULL, [calendar_month] [int] NULL, [calendar_week] [int] NULL, [...
0
votes
1answer
19 views

Update geometries with ST_UnaryUnion at TRIGGER

We are currently working on database with multipolygons and we're using QGIS 3. Sometimes it's very useful to work with parts (each page of document is separate part of multipolygon), however at the ...
2
votes
0answers
28 views

Trigger - Calculate area of a layer inside feature by changing the inner layer

Working with PostGIS database and QGIS, I have two polygons layers, an external with land lots (lotes) and an internal with building area (areaconstruida). In the "lotes" layer, I need a field in ...
1
vote
1answer
35 views

Trigger - Calculate area of a layer inside feature

I'm trying to create a trigger to auto-fill a field of a table in postGIS based on two polygon layers geometry. I'm using QGIS for geometry updates. The first layer (lotes) has bigger polygons and ...
1
vote
1answer
49 views

Geometry based automatic fill of fields in attribute table

I'm looking for solutions for auto-fill attribute table fields of spatial layer on QGIS from updates in geometry. All layers were created as polygon shapefiles. Attribute table fields are dependent ...
2
votes
1answer
53 views

Trigger PostGIS QGIS

I have 2 layers on PostGIS: a point layer named 'tdia' and a polygon layer named 'com': -the com layer contains the city name. (Polygon) -the tdia layer contains bus stops. (point) I want to create a ...
1
vote
0answers
36 views

How to Create 'Update Triggers' to Track Field Values Changes When Data is Versioned?

How can I create a trigger to capture when a field is changed from one value to another if my data is versioned? I am not able to run an UPDATE trigger and grab ':new' and ':old' values because with ...
0
votes
0answers
31 views

Automating Redshift data dump to a PostgreSQL DB every 12 hours

I have a redshift database that changes multiple times a day. I want to use this "live" data to make web maps and I have a Postgres DB where all my web-mapping data is stored. I want to continuously ...
3
votes
1answer
87 views

PostGIS trigger does not work as expected while checking intersections

I'm trying to write a trigger that should prevent saving lines which do not end at building boundaries. ( A PostGIS-Solution for something like the topology-rule "Must be covered by boundary of" in ...
1
vote
0answers
23 views

Trigger history_ How can I define the last updated column?

I am trying to implement a trigger function in PostgreSQL. I've written this trigger history function: CREATE OR REPLACE FUNCTION history_update() RETURNS trigger AS $$ BEGIN INSERT INTO ...
1
vote
1answer
39 views

Adding per-row creation time and modification time in GeoPackage geometry table?

I need to add ctime and mtime to a GPKG sqlite database in table with geometry. Apparently logic solution: add ctime column with DEFAULT CURRENT_TIMESTAMP and add trigger ON UPDATE to set mtime = ...
0
votes
0answers
33 views

Automatically Trigger write fields from polygon to point when adding point

When editing, I would like to create an SQL trigger that will write fields from my parcels layer to a point layer that the end user is editing. Essentially, when a point is placed on a parcel, that ...
1
vote
1answer
72 views

Updating PostgreSQL geometry column using SQL (Trgger)

I'm looking to inderstand the role of date_part('epoch'::text, now()) WHERE id=NEW.id; in the trigger function below. CREATE OR REPLACE FUNCTION fn_test_table_geo_update_event() RETURNS trigger AS $...
0
votes
0answers
63 views

How to populate the actions table in a osm postgres/postgis database

I have a postgres/postgis osm database and I wanted to track changes using the actions table produced from osmosis. How so I go about populating that table? I ran the action.sql listed below but ...
1
vote
0answers
31 views

QGIS plpgsql RAISE MESSAGEs do not appear in QGIS Log Messages Panel | PostGIS Tab

I refer to this post Show "Raise Notice" and "Raise Warning" in QGIS and to the herein referred issue https://issues.qgis.org/issues/12184#change-59414. Using QGIS 2.18.18 LTR I ...
1
vote
0answers
129 views

Insert new rows in table using QGIS and PostGIS view and do instead trigger

I have a table with roads and use a view to populate descriptive fields from look-up tables. I can see the view in QGIS and would like to use it to add new roads using a DO INSTEAD trigger. Currently ...
2
votes
0answers
94 views

Create PostGIS trigger that splits lines

I have a table with LINESTRING where one condition is for lines to be composed of only 2 vertices. I want the user to be able to create, or import lines with more than 2 vertices, but upon feature ...
0
votes
0answers
88 views

Can ArcMap autopopulate a consecutive number as an action?

I am using the Collector app and would like to autopopulate an integer into a particular field in my layer. I've seen ESRI's help pages that show "Setting an attribute trigger for an action" but not ...
0
votes
1answer
485 views

Use a sde.st_geometry function in a PL/SQL trigger

I have a PL/SQL trigger: 1 create or replace trigger "projects_to_meas_trig" before update of asset_id 2 on projects 3 4 for each row 5 declare 6 v_length number; 7 begin 8 ...
1
vote
1answer
294 views

PostgreSQL 'BEFORE INSERT' TRIGGER Problem with QGIS

In PostgreSQL I created a simple PL/pgSQL trigger function like this: CREATE OR REPLACE FUNCTION set_rv_default_farben() RETURNS trigger AS $$ BEGIN IF NEW.parent_rv IS NULL THEN IF NEW....
3
votes
0answers
110 views

How to restrict user to change (move) only one point in QGIS with Oracle Spatial database connected

I'm working with an Oracle Spatial View (Oracle Database 11g Enterprise, 64bit) in QGIS (2.18.0). There was the bad case that I (and other user) was selecting a lot of points and accidentally moved ...
2
votes
0answers
46 views

Populate b.field into a.field when 2 vector points not always coincident but should be coincident

Using QGIS/pgAdmin3, I have a situation where two vector points, should be coincident but I can't guarantee they always are, I need to take feature a.field and populate a field in feature b, upon both ...
1
vote
0answers
49 views

Writing trigger which calculates driving distance?

Trigger fires but doesn't update my table - COUNTY_VR_GEO_ROUTING. Here's the output from pgadmin after updating a record - UPDATE 2 Query returned successfully in 2 secs. Can anyone give me ...
1
vote
0answers
666 views

postgresql trigger with FOR EACH ROW affect nonaffected rows [closed]

Im making a INSERT/UPDATE trigger to populate a geometry column from a text column containing a WKT string. But now its overwriting all rows! CREATE TABLE public.teams ( name text, coverage_wkt ...
1
vote
0answers
60 views

SQL trigger that dissolves feature class based on multilabel fields

I am about write an SQL trigger which dissolves a feature class based on 5 fields, I used to do this using dissolve tool in the Arcmap as the following screenshots: Now, I need this process to be ...
2
votes
1answer
257 views

Setting python code to trigger on any update on feature class?

For example, when I have a geometry change on a point, I would like to update the X and Y fields to the new current location, I understand how to make the code, but not where do I set or put it to be ...
1
vote
1answer
341 views

Geometry type and create trigger for that in postgresql

I want to create a trigger (before inserting trigger), to check the geometry type weather is point, polygon, line, or multi-polygon. After that, I want to set the color property. How can I do this? I ...
4
votes
1answer
969 views

ArcSDE 10.1 Insert/Update Trigger on Adds (A) Table (Oracle 11g) and Feature Services on ArcGIS Server

I'm trying to use a trigger to update a versioned dataset in an SDE environment. Basically, I wanted to implement a system of unique ids called GISID. Initially, when a feature is created (inserted), ...
1
vote
0answers
104 views

QGIS crashes when using PostgreSQL/PostGIS triggers

When using PostgreSQL/PostGIS triggers saving layer edits gets slower and slower every time when saving a layer edit. This issue occurs after a few up to a few dozen saved layer edits. Finally QGIS ...
4
votes
1answer
668 views

How to create trigger to check geometry validity?

I want to create trigger to check geometry validity in spatial table. I have a table: CREATE TABLE vec_geometry ( id bigserial is_valid boolean, invalid_reason character(128), geom ...
7
votes
2answers
2k views

How to use interacting PostgreSQL/PostGIS triggers in QGIS to create multiple labels on polygons?

EDIT: The trigger functions posted are well done but there are still a few issues. I've uploaded two screen recordings: http://workupload.com/file/ygRnYtp9 http://workupload.com/file/OBY7i9Fh I ...
4
votes
1answer
690 views

How to set/update columns by using a trigger?

I want to set/update attributes (alignment_horizontal, alignment_vertical) of a PostGIS geometry (point) by using a trigger. CREATE TABLE point ( gid serial NOT NULL, geom geometry(point, SRID), ...
3
votes
0answers
55 views

Creat point count trigger in PostgreSQL?

I wish to create a trigger in PostgreSQL for counting points in a polygon. The tweak is that the count should automatically get updated whenever the polygon is edited. Can anyone please help me on ...
3
votes
1answer
2k views

How to create a trigger for multiple schemas?

One of my PostgreSQL databases contains different schemas which share the same structure. -- schema region_a CREATE TABLE region_a.point ( gid serial NOT NULL, geom geometry(point, SRID), ...
1
vote
1answer
123 views

trigger postgis and dump qgis 2.8.2

I created a trigger that checks if geometry is valid on insert and update. create or replace function check_geom() returns trigger as $$ begin --insert a polygon IF st_isvalid(new.geom) = 'f' ...
2
votes
0answers
37 views

Add individual fields to delete-log-trigger when deleting PostGis-Objects via QGis [closed]

I am using a PostGres Database with PostGis extension (on Windows). QGis serves as a client to access (visualize and edit) certain database-tables. I need to create a delete-log-table that saves all ...
2
votes
1answer
4k views

Adding SQL Trigger to update field on INSERT (multiple rows)

I have an address point Feature Class that has an addressID field. I am trying to write a trigger that will in effect auto increment this field when a new address is added to the map. I cannot alter ...
1
vote
2answers
92 views

GIS and Geodatabase with Reminder Function

a friend of mine, a landscape gardener, asked me wether it is possible to represent his garden (mainly big trees and a few flower fields) in a GIS so he could administrate these on his computer by ...
1
vote
2answers
945 views

Using PostGIS trigger?

I'm trying to update a lat and lon columns each time I insert a point with a trigger, but I don't know why I get an error. This is the syntax I'm writing: CREATE OR REPLACE FUNCTION update_tg2() ...
1
vote
2answers
10k views

Using PostgreSQL trigger on table that updates field? [closed]

Depending on values on 2 fields A and B, I would like a field C to be updated or filled with a specific value. For example : create or replace function periode() returns trigger as $BODY$ begin IF A ...
2
votes
1answer
104 views

How do I catch PostgreSQL/ PostGIS RAISE messages in OpenLayers?

Is it possible to catch Raise Warning, Raise Notice and Raise Exception in OpenLayers while using a WFS-T-Layer (stored in a PostGIS-Database) to save edits? Example: A trigger is used to check values ...
4
votes
1answer
625 views

Show “Raise Notice” and “Raise Warning” in QGIS

Is there a way to catch "Raise Warning" and "Raise Notice" (while editing PostGIS-Layers) from a PostgreSQL/PostGIS-Trigger-Function within QGIS? One example: I have a trigger that reacts to insert or ...
1
vote
1answer
246 views

plpgsql combine ST_Overlaps and ST_Intersects

I have a question regarding creating a trigger function in postgres with two conditions: When creating a linestring in QGIS there must be either overlap nor intersect. So I wrote two functions, each ...
1
vote
1answer
931 views

How to create postgresql triggers to calculate geometry from x,y and vice versa at the same time

I have a postgis table with point geometry which looks like this CREATE TABLE mypoints ( gid serial NOT NULL, coordid integer, geom geometry(Point,4326) ); And a table with coordinates like ...
1
vote
2answers
239 views

postgresql rule to trigger

I have two spatial tables and I am mirroring the data between the two table with a postgres rule: CREATE OR REPLACE RULE create_centroid AS ON INSERT TO csg.client_area_request DO INSERT INTO csg....
1
vote
1answer
1k views

Aggregate functions not allowed in trigger

I need help with a postgres/postgis trigger. I have a table of retaining walls, each of which is associated with the adjacent road, except where the wall abuts a junction, where it will be split and ...
2
votes
2answers
263 views

How to setup a SQL trigger in CartoDB

I need to setup 2 SQL triggers in CartoDB that will update my inland and coastal tables each time my obs table is updated. I have never setup a SQL trigger but I have looked at the documentation and ...
2
votes
1answer
124 views

Automatically updating column in feature class when another column is changed?

I have a feature class in a file geodatabase and it contains a field called [curing] in short integer type and another field called [IsPopulated] in short integer as well. What I want to achieve is ...
1
vote
1answer
815 views

PostgreSQL Trigger on inherited tables [closed]

In my PostgreSQL I have a parent table and a number of child tables (inherited from the parent table). How to create a trigger which will be bind to all the current and future child tables derived ...
2
votes
0answers
181 views

How to simulate events from Openlayers 2?

I am working on a GIS API that uses OpenLayers. I am testing it using QUnit. The problem is I need to simulate clicks and trigger some events to be able to test the whole code. For example, I have a ...