From: shaun <savages@mozapps.org>
To: pgsql-sql@postgresql.org
Subject: CREATE USER in side a TRIGGER FUNCTION
Date: Thu, 14 Apr 2005 20:30:02 -0700
Message-ID: <425F353A.6060700@mozapps.org> (raw)
Hi
I want to put login and user managment into the database for security
reasons. I have a employee table. When I add a person to the employee
table I want to create them in the database and when I remove a person I
want to drop the person from the database also. How do you do it and
what is wrong the the following code?
shaun
here is the add person trigger.
CREATE FUNCTION insuser () RETURNS TRIGGER AS
'BEGIN
IF NEW.role = ''clerk'' THEN
EXECUTE CREATE USER NEW.login IN GROUP gp_clerk;
ELSIF NEW.role = ''medic'' THEN
EXECUTE CREATE USER NEW.login IN GROUP gp_medic;
ELSIF NEW.role = ''super'' THEN
CREATE USER NEW.login IN GROUP gp_super;
ELSIF NEW.role = ''admin'' THEN
CREATE USER NEW.login CREATEUSER IN GROUP gp_admin;
ELSIF NEW.role = ''maint'' THEN
CREATE USER NEW.login CREATEUSER IN GROUP gp_maint;
END IF;
RETURN NEW;
END;'
LANGUAGE plpgsql;
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: savages@mozapps.org
Subject: Re: CREATE USER in side a TRIGGER FUNCTION
In-Reply-To: <425F353A.6060700@mozapps.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox