Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 68C36B5DC00 for ; Wed, 19 Oct 2011 08:32:42 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 21024-05 for ; Wed, 19 Oct 2011 11:32:36 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0-rc2 Received: from mailout01.ims-firmen.de (mailout01.ims-firmen.de [213.174.32.96]) by mail.postgresql.org (Postfix) with ESMTP id CAE45B5DC04 for ; Wed, 19 Oct 2011 08:32:35 -0300 (ADT) Received: from mailin04.ims-firmen.de ([192.168.1.113]) by mailout01.ims-firmen.de with esmtp (envelope-from ) id 1RGUNu-00067t-7m; Wed, 19 Oct 2011 13:32:34 +0200 Received: from [213.174.32.34] (helo=oxweb01.ims-firmen.de) by mailin04.ims-firmen.de with esmtpsa (TLSv1:RC4-MD5:128) (envelope-from ) id 1RGUNu-0000Jx-7A; Wed, 19 Oct 2011 13:32:34 +0200 Date: Wed, 19 Oct 2011 13:32:32 +0200 (CEST) From: Andreas Kretschmer To: =?UTF-8?Q?=22Brice_Andr=C3=A9=22?= , pgsql-sql@postgresql.org Message-ID: <682203673.92.1319023952704.JavaMail.open-xchange@oxweb01.ims-firmen.de> In-Reply-To: References: Subject: Re: Problem with DROP ROLE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Priority: 3 Importance: Medium X-Mailer: Open-Xchange Mailer v6.20.0-Rev24 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-5 required=5 tests=BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001 X-Spam-Level: X-Archive-Number: 201110/71 X-Sequence-Number: 35955 You can't do that in THAT way, but you can use dynamic SQL: =C2=A0 test=3D# select * from drop_role ; =C2=A0=C2=A0 t -------- =C2=A0foobar (1 row) test=3D*# 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; =C2=A0 DO=C2=A0 =C2=A0 =C2=A0 "Brice Andr=C3=A9" hat am 19. Oktober 2011 um 12:1= 1 geschrieben: > Hello everyone, >=20 > 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 every= thing > 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) >=20 > So, does someone knows how to handle this problem ? >=20 > Regards, > Brice >