variables in functions .. - Mailing list pgsql-general

From Peter Pilsl
Subject variables in functions ..
Date
Msg-id 20011024223634.J34156@i3.atat.at
Whole thread Raw
List pgsql-general
I need a query like

select column,x from table where .... order by ...;

where x should return 0 for the first shown entry, 10 for the second,
20 for the third and so on. Is there a way to create a function doing
this (it needs a memory or needs to have access to some internal
variables).

However, this is not the realworld-example. The original task is:
select 6 values out of 10 tables trought sorting each table internal
according to a 'ranking'-functions and then choose the highest 6, but
as soon as entry from one table is choosen, the others should be
ranked down by 10, so two entries from the same table will only be
choosen if all other entried are ranked very bad ...

I wonder if there is a fast SQL-operation to do so or if I'm faster
off by doing it in C or perl outside. This problem reduces to the
above question...

thnx,
peter

--
mag. peter pilsl

phone: +43 676 3574035
fax  : +43 676 3546512
email: pilsl@goldfisch.at
sms  : pilsl@max.mail.at

pgp-key available

pgsql-general by date:

Previous
From: "Joop van Bussel"
Date:
Subject: Function won't compile
Next
From: Thomas Lockhart
Date:
Subject: Re: Disable Transaction - plans ?