pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andreas Kretschmer <andreas@a-kretschmer.de>
To: "Brice André" <brice@famille-andre.be>
To: pgsql-sql@postgresql.org
Subject: Re: Problem with DROP ROLE
Date: Wed, 19 Oct 2011 13:32:32 +0200 (CEST)
Message-ID: <682203673.92.1319023952704.JavaMail.open-xchange@oxweb01.ims-firmen.de> (raw)
In-Reply-To: <CAOBG12mCa-07QW==228ieiosV_TKWK8wAowAhW+kXSkyVkfY9Q@mail.gmail.com>
References: <CAOBG12mCa-07QW==228ieiosV_TKWK8wAowAhW+kXSkyVkfY9Q@mail.gmail.com>

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@famille-andre.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
>



view thread (4+ messages)  latest in thread

Message-ID: <682203673.92.1319023952704.JavaMail.open-xchange@oxweb01.ims-firmen.de>
Permalink:  ../682203673.92.1319023952704.JavaMail.open-xchange@oxweb01.ims-firmen.de/
Also on:    postgresql.org/message-id/682203673.92.1319023952704.JavaMail.open-xchange@oxweb01.ims-firmen.de

 · 

reply

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: andreas@a-kretschmer.de, brice@famille-andre.be
  Subject: Re: Problem with DROP ROLE
  In-Reply-To: <682203673.92.1319023952704.JavaMail.open-xchange@oxweb01.ims-firmen.de>

* 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