Skip site navigation (1) Skip section navigation (2)

problem with automatic altering of groups

From: "Matthias Nagl" <mnagl(at)web(dot)de>
To: pgsql-sql(at)postgresql(dot)org
Subject: problem with automatic altering of groups
Date: 2003-08-20 21:09:08
Message-ID: 200308202109.h7KL98Q30820@mailgate5.cinetic.de (view raw or flat)
Thread:
Lists: pgsql-sql
Hello, 
 
is ist possible to write a function that alters the group of a given user like the following should do in my 
opinion (I'd like to use it in a rule): 
 
CREATE FUNCTION set_group (text, integer) RETURNS text AS ' 
	ALTER GROUP userlevel1 DROP USER $1; ALTER GROUP userlevel2 DROP USER $1; ALTER GROUP 
userlevel3 DROP USER $1; 
	ALTER GROUP userlevel4 DROP USER $1; ALTER GROUP userlevel5 DROP USER $1; 
	CASE $2 
		WHEN 5 THEN 
			(ALTER GROUP userlevel5 ADD USER $1) 
		WHEN 4 THEN 
			(ALTER GROUP userlevel5 ADD USER $1; ALTER GROUP userlevel4 ADD USER $1;) 
		[...] 
	END; 
	SELECT ''; 
' LANGUAGE 'SQL'; 
 
I don't understand why this function ist refused by postgresql with an parse error at the first $1 as ist every 
other method I tryed to get postgres making an "alter group" with a variable. I'd be very happy if someone 
could help... 
 
yours 
 
Matthias Nagl 
__________________________________________________________________________
Die sicherste Form der Kommunikation: E-Mails verschluesseln, Spam-Filter,
Adressverifizierung, digitale Unterschrift: http://freemail.web.de


pgsql-sql by date

Next:From: Roberto MelloDate: 2003-08-20 21:12:25
Subject: Re: Porting from PL/SQL to PLPGSQL
Previous:From: Tom LaneDate: 2003-08-20 20:53:22
Subject: Re: Before/After Trigger User Switching

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group