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

Re: GRANT SELECT ON table TO $1

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "David Barajas" <david(at)sonrie(dot)net>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: GRANT SELECT ON table TO $1
Date: 2006-10-31 03:51:59
Message-ID: 23445.1162266719@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-novice
"David Barajas" <david(at)sonrie(dot)net> writes:
> CREATE OR REPLACE FUNCTION func(TEXT)
> RETURNS integer
> AS $$
> BEGIN
>   GRANT SELECT ON table1 TO $1;

Can't do that: a $-parameter is a placeholder for a data value, not a
name, and GRANT wants a name.  You could do

	EXECUTE 'GRANT SELECT ON table1 TO ' || quote_ident($1);

			regards, tom lane

In response to

pgsql-novice by date

Next:From: Lenorovitz, JoelDate: 2006-10-31 20:20:48
Subject: Trouble with plpgsql generic trigger function using special variables
Previous:From: David BarajasDate: 2006-10-31 03:39:05
Subject: GRANT SELECT ON table TO $1

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