Re: Select all fields except one

From: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
To: David Fetter <david(at)fetter(dot)org>
Cc: Matt Doughty <matt(dot)doughty(at)geograma(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Select all fields except one
Date: 2007-11-28 17:47:19
Message-ID: 20071128094719.44557bbe@commandprompt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Wed, 28 Nov 2007 09:37:43 -0800
David Fetter <david(at)fetter(dot)org> wrote:

> On Wed, Nov 28, 2007 at 05:06:45PM +0100, Matt Doughty wrote:
> > Hi,
> >
> > Is there a way of selecting all fields except for one in particular?
> > I'd like to create a query that says something like:
> >
> > select * except fieldx
> >
> > What I'm hoping to achieve is a query that can be valid for a number
> > of different tables, although the field I don't want to select is
> > always called the same (field_not_wanted, for example).
>
> This sounds like self-modifying code. I'd submit that you're trying
> to do the wrong thing in the first place, and that you should look
> over your design for flaws like this and re-do that design.

Or to actually try to be helpful, you could consider using a server
side function instead:

select * from global_query({},TEXT);

Where the array list is is the list of fields you don't want selected
and the second parameter is the table you are going to use. Then you
just have to build the logic inside the function.

Sincerely,

Joshua D. Drake

>
> Cheers,
> David.

- --

=== The PostgreSQL Company: Command Prompt, Inc. ===
Sales/Support: +1.503.667.4564 24x7/Emergency: +1.800.492.2240
PostgreSQL solutions since 1997 http://www.commandprompt.com/
UNIQUE NOT NULL
Donate to the PostgreSQL Project: http://www.postgresql.org/about/donate
PostgreSQL Replication: http://www.commandprompt.com/products/

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFHTamnATb/zqfZUUQRArcrAJwIfarEnOPTzE8nzoWOfocW2C1kyQCgm4iU
e6DgUTvJD3bJDarJkoVpk7Y=
=GO+V
-----END PGP SIGNATURE-----

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Merlin Moncure 2007-11-28 17:50:03 Re: Select all fields except one
Previous Message Merlin Moncure 2007-11-28 17:43:51 Re: PostgresSQL vs. Informix