Trigger: User AFTER UPDATE

15 views
Skip to first unread message

Chris Berens

unread,
Jan 30, 2018, 3:31:46 AM1/30/18
to SpatiaLite Users
Hi there,

We are struggling to write a trigger that references the logged in user after update to a record:

CREATE TRIGGER upd_user

AFTER UPDATE

ON list

BEGIN

UPDATE list

SET crupd_name = current_user

WHERE ogc_fid = OLD.ogc_fid;

END;


Cuurently QGIS does not enable tis on update (only on insert). Is there a way of doing this in a SpatiaLite database? Clearly my 'current_user' is wishful thinking.

Regards,
Chris


mj10777

unread,
Jan 30, 2018, 4:12:42 AM1/30/18
to SpatiaLite Users


On Tuesday, 30 January 2018 09:31:46 UTC+1, Chris Berens wrote:
Hi there,

We are struggling to write a trigger that references the logged in user after update to a record:

CREATE TRIGGER upd_user

AFTER UPDATE

ON list

BEGIN

UPDATE list

SET crupd_name = current_user

WHERE ogc_fid = OLD.ogc_fid;

END;

The TRIGGER Syntax looks ok.
- but where are you going to get the value of 'current_user' from? 
It may (never tried) be possible to execute a sub-query. if the value of 'current_user' is stored somewhere that can be queried.

Mark

Chris Berens

unread,
Jan 30, 2018, 4:16:57 AM1/30/18
to SpatiaLite Users
Hi Mark,

Maybe lazy but I am hoping to user the OS user account or user_full_name here.

mj10777

unread,
Jan 30, 2018, 5:48:12 AM1/30/18
to SpatiaLite Users


On Tuesday, 30 January 2018 10:16:57 UTC+1, Chris Berens wrote:
Hi Mark,

Maybe lazy but I am hoping to user the OS user account or user_full_name here.
Google brings as the first result for 'sqlite3 sql retrieve environment variable' this:

which tells you that sql cannot retrieve environment variable such as '%USER'.

Without a Magic-Wand ....

Mark
Reply all
Reply to author
Forward
0 new messages