Re: Problem with DROP ROLE

From: Brice André <brice(at)famille-andre(dot)be>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: Problem with DROP ROLE
Date: 2011-10-19 12:19:56
Message-ID: CAOBG12=2YYZ5goZmS3jaW4kv1sWEQwe9eFa_s6G5qC-JiXbEGw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Thanks very much. I replaced my statement by the following plpgsql code :

statement := 'DROP ROLE "'||(SELECT ...)||'";';
execute(statement);

and it works like a charm.

Regards,
Brice

2011/10/19 Andreas Kretschmer <andreas(at)a-kretschmer(dot)de>

> You can't do that in THAT way, but you can use dynamic SQL:
>
> test=# select * from drop_role ;
> t
> --------
> foobar
> (1 row)
>
> test=*# do $$ declare r text; begin for r in select t from drop_role loop
> execute 'drop role ' || quote_ident(r) || ';'; end loop; end; $$language
> plpgsql;
>
> DO
>
>
>
>
> "Brice André" <brice(at)famille-andre(dot)be> hat am 19. Oktober 2011 um 12:11
> geschrieben:
>
>
> > Hello everyone,
> >
> > I would want to implement an SQL query where I would be able to suppress
> all
> > information from a registered user. I am currenlty able to suppress
> everything
> > except the user role. The name of the role is present in a table and so,
> I
> > would want to perform something like this :
> > DROP ROLE (SELECT ...)
> > but this is not considered as valid, as DROP ROLE is expecting a name and
> not
> > a text field. So, I tried the following, but with no success :
> > DROP ROLE CAST((SELECT...) AS name)
> >
> > So, does someone knows how to handle this problem ?
> >
> > Regards,
> > Brice
> >
>

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Rich 2011-10-19 14:08:16 How to write sql to access another odbc source.
Previous Message Guillaume Lelarge 2011-10-19 11:59:00 Re: Problem with DROP ROLE