Search Postgresql Archives

Random multiple times

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I understand random() is a volatile function and runs multiple times for multiple rows returned by a SELECT, however is there a way of getting it to run multiple times *within* another function call and in the same row. i.e. something like

select regexp_replace('+1 555 555 555', E'\\d', trunc(random() * 9 + 1)::text,'g');
 regexp_replace 
----------------
 +1 111 111 111
(1 row)

As you can see, it returns the same digit each time. I've tried wrapping a select around the trunc too.

Regards
Oliver Kohll
www.gtwm.co.uk / www.agilebase.co.uk




-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux