Random multiple times - Mailing list pgsql-general

From Oliver Kohll - Mailing Lists
Subject Random multiple times
Date
Msg-id 81771A6B-84F3-4014-B5D3-206B523FE5FB@gtwm.co.uk
Whole thread Raw
Responses Re: Random multiple times
Re: Random multiple times
List pgsql-general
Hi,

I understand random() is a volatile function and runs multiple times for multiple rows returned by a SELECT, however is
therea 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




pgsql-general by date:

Previous
From: Devrim GÜNDÜZ
Date:
Subject: Re: pg-9.1 for fedora 15 available?
Next
From: Szymon Guz
Date:
Subject: Re: Random multiple times