Re: Problem with volatile function

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Problem with volatile function
Дата
Msg-id 25613.1213847000@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Problem with volatile function  (Artacus <artacus@comcast.net>)
Список pgsql-general
Artacus <artacus@comcast.net> writes:
> I have a function random(int, int) that returns a random value between
> $1 and $2. I want to use it in a query to generate values. But it only
> evaluates once per query and not once per row like I need it to.

> -- This always returns the same value
> SELECT ts.sis_id, bldg_id, f_name.name, l_name.name
> FROM tmp_students ts
> JOIN names AS f_name ON
>    ts.gender = f_name.gender
> WHERE f_name.counter = random(1,300)

You haven't really explained what your problem is, but offhand I'd
expect random() to be evaluated once per f_name row here.  What are
you looking for?

            regards, tom lane

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

Предыдущее
От: Artacus
Дата:
Сообщение: Problem with volatile function
Следующее
От: Craig Ringer
Дата:
Сообщение: Re: Problem with volatile function