pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Richard Huxton <dev@archonet.com>
To: Carlos Santos <carlos@compels.net>
Cc: Lista PostgreSQL SQL <pgsql-sql@postgresql.org>
Subject: Re: SELECT with WHERE clause by column number
Date: Mon, 18 Dec 2006 17:25:27 +0000
Message-ID: <4586CF07.9000900@archonet.com> (raw)
In-Reply-To: <20061218171739.98671.qmail@web57105.mail.re3.yahoo.com>
References: <20061218171739.98671.qmail@web57105.mail.re3.yahoo.com>

Carlos Santos wrote:
> SELECT id FROM myTable WHERE column-number = 'value';
> (PS: The id column is the primary key of myTable).
> 
> That is a select using column number in the WHERE clause what don't exists in SQL.
> 
> I need this because there's a situation in my program where I don't have the column name.
> I've solved that querying Postgresql the name of the column with that number, and then creating  the SELECT query.
> But this solution is slow... two database calls...

If you don't know what the column is, how do you know what you are 
testing against? Or what type it is, for that matter?

Anyway, just have build a list of column-name,column-type pairs for 
relevant tables at application start-up, or store it in a configuration 
file. Unless you're building/changing tables all the time, that should work.

I'm curious as to what type of application can usefuly query a database 
without knowing what structure it has.

-- 
   Richard Huxton
   Archonet Ltd



view thread (4+ messages)  latest in thread

Message-ID: <4586CF07.9000900@archonet.com>
Permalink:  ../4586CF07.9000900@archonet.com/
Also on:    postgresql.org/message-id/4586CF07.9000900@archonet.com

 · 

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: dev@archonet.com, carlos@compels.net
  Subject: Re: SELECT with WHERE clause by column number
  In-Reply-To: <4586CF07.9000900@archonet.com>

* 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