Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id AFB2FB5DBC2 for ; Wed, 19 Oct 2011 08:59:09 -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 70555-08 for ; Wed, 19 Oct 2011 11:59:03 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0-rc2 Received: from sd-17937.dedibox.fr (sd-17937.dedibox.fr [88.191.100.74]) by mail.postgresql.org (Postfix) with ESMTP id D8AFAB5DBC0 for ; Wed, 19 Oct 2011 08:59:02 -0300 (ADT) Received: from [192.168.109.75] (manaslu.utelisys.net [217.117.239.6]) by sd-17937.dedibox.fr (Postfix) with ESMTPA id 5D1A83B8EE; Wed, 19 Oct 2011 13:59:01 +0200 (CEST) Subject: Re: Problem with DROP ROLE From: Guillaume Lelarge To: Brice =?ISO-8859-1?Q?Andr=E9?= Cc: pgsql-sql@postgresql.org Date: Wed, 19 Oct 2011 13:59:00 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.0.3 (3.0.3-1.fc15) Content-Transfer-Encoding: 8bit Message-ID: <1319025541.2112.1.camel@localhost.localdomain> Mime-Version: 1.0 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 X-Spam-Level: X-Archive-Number: 201110/33 X-Sequence-Number: 35917 On Wed, 2011-10-19 at 12:11 +0200, Brice André wrote: > 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 ? > You can't do it with only one query. You need to use two queries: the SELECT, and then the DROP. -- Guillaume http://blog.guillaume.lelarge.info http://www.dalibo.com