Re: Select all fields except one - Mailing list pgsql-general

From Joshua D. Drake
Subject Re: Select all fields except one
Date
Msg-id 20071128094719.44557bbe@commandprompt.com
Whole thread Raw
In response to Re: Select all fields except one  (David Fetter <david@fetter.org>)
Responses Re: Select all fields except one  (David Fetter <david@fetter.org>)
List pgsql-general
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Wed, 28 Nov 2007 09:37:43 -0800
David Fetter <david@fetter.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-----

pgsql-general by date:

Previous
From: "Merlin Moncure"
Date:
Subject: Re: PostgresSQL vs. Informix
Next
From: "Merlin Moncure"
Date:
Subject: Re: Select all fields except one