Re: stored procedure

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: stored procedure
Дата
Msg-id 3555.1049230137@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: stored procedure  (Peter Choe <choepete@mindspring.com>)
Список pgsql-general
Peter Choe <choepete@mindspring.com> writes:
> i do the following:
> select c from charkey where idx=((4 * random())::int)%4;
> sometimes i get one character back (which is good), but other times, i
> get two characters or none.

The WHERE clause is re-evaluated at each row, so you get a new random
value each time.  You need to compute *one* random value and then pull
the matching row out of the table.

            regards, tom lane


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