Res: SELECT with WHERE clause by column number

Поиск
Список
Период
Сортировка
От Carlos Santos
Тема Res: SELECT with WHERE clause by column number
Дата
Msg-id 20061218183649.23058.qmail@web57105.mail.re3.yahoo.com
обсуждение исходный текст
Список pgsql-sql
All my columns have the same data type: text.
So it's much easier.
 
Carlos Henrique Iazzetti Santos
Compels Informática
Santa Rita do Sapucaí - MG
www.compels.net


----- Mensagem original ----
De: Richard Huxton <dev@archonet.com>
Para: Carlos Santos <carlos@compels.net>
Cc: Lista PostgreSQL SQL <pgsql-sql@postgresql.org>
Enviadas: Segunda-feira, 18 de Dezembro de 2006 15:25:27
Assunto: Re: [SQL] SELECT with WHERE clause by column number

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

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

               http://archives.postgresql.org



Você quer respostas para suas perguntas? Ou você sabe muito e quer compartilhar seu conhecimento? Experimente o Yahoo! Respostas!

В списке pgsql-sql по дате отправления:

Предыдущее
От: "Aaron Bono"
Дата:
Сообщение: Re: SELECT with WHERE clause by column number
Следующее
От: Ragnar
Дата:
Сообщение: Re: SELECT with WHERE clause by column number