Обсуждение: row-specific conditions possible?

Поиск
Список
Период
Сортировка

row-specific conditions possible?

От
Jörg Kiegeland
Дата:
Hi,

I want to store a boolean SQL condition in a column "condition_column"
of my table "myTable".
This condition refers to other columns of the same table and shall use
one parameter, e.g. "column1=4 AND colume2+column3=param".
Every row has a different condition in general..

So my query on the table should look like "SELECT * FROM myTable WHERE
anotherCondition AND EXECUTE condition_column(7)"
In this example, the concrete argument is "7".
However EXECUTE can only be used for prepared statements, and I dont
know how to prepare a statement within one single SQL query.
Does anybody know?

Our current solution is to execute "SELECT * FROM myTable WHERE
anotherCondition" where "anotherCondition" selects ~30% of the table,
and we evaluate the row-specific condition on client-side by our own
condition-evaluator, so that we finally have ~1% from the whole table as
result.
This however fetches 1/3 of the table over a remote JDBC connection. Its
clear that a server-side evaluation would also scan 1/3 of the table,
however only the final result would be transfered to the client.

Thanks for any help!

Re: row-specific conditions possible?

От
"A. Kretschmer"
Дата:
In response to Jörg Kiegeland :
> Hi,

This list, [Perform], is obviously the wrong list for such...

>
> I want to store a boolean SQL condition in a column "condition_column"
> of my table "myTable".
> This condition refers to other columns of the same table and shall use
> one parameter, e.g. "column1=4 AND colume2+column3=param".
> Every row has a different condition in general..

maybe this blog-entry can help you:
http://akretschmer.blogspot.com/2007/10/postgresql-formula-in-column-how.html


For further questions ask me privat.


Andreas
--
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID:   0x3FFF606C, privat 0x7F4584DA   http://wwwkeys.de.pgp.net