Re: some random() clarification needed

2020-07-15 Thread Marc Millas
Thanks! makes it clearer :-) its not that obvious to guess the consequences of the "volatile" behaviour. regards, Marc MILLAS Senior Architect +33607850334 www.mokadb.com On Wed, Jul 15, 2020 at 1:53 AM David Rowley wrote: > On Wed, 15 Jul 2020 at 04:01, Marc Millas wrote: > > your answer

Re: some random() clarification needed

2020-07-14 Thread David Rowley
On Wed, 15 Jul 2020 at 04:01, Marc Millas wrote: > your answer helps me understand my first problem. > so, I rewrote a simple loop so as to avoid the "volatile" behaviour. Not sure what you're trying to do with the plpgsql, but you can just escape the multiple evaluations by putting the volatile

Re: some random() clarification needed

2020-07-14 Thread Adrian Klaver
On 7/14/20 9:01 AM, Marc Millas wrote: Hi, your answer helps me understand my first problem. so, I rewrote a simple loop so as to avoid the "volatile" behaviour. (at least I was thinking I did... looks like I was wrong !) step by step loop: DO $$ BEGIN   FOR counter IN 1..1000 LOOP begin

Re: some random() clarification needed

2020-07-14 Thread David G. Johnston
Please don't top-post. Inline (with trim) is better but at minimum bottom-post. On Tue, Jul 14, 2020 at 9:01 AM Marc Millas wrote: > Hi, > your answer helps me understand my first problem. > so, I rewrote a simple loop so as to avoid the "volatile" behaviour. > (at least I was thinking I

Re: some random() clarification needed

2020-07-14 Thread Marc Millas
Hi, your answer helps me understand my first problem. so, I rewrote a simple loop so as to avoid the "volatile" behaviour. (at least I was thinking I did... looks like I was wrong !) step by step loop: DO $$ BEGIN FOR counter IN 1..1000 LOOP begin declare id1 integer =ceiling(random()*2582); id3

Re: some random() clarification needed

2020-07-14 Thread Marc Millas
Ok, thanks for the clarification. Marc MILLAS Senior Architect +33607850334 www.mokadb.com On Tue, Jul 14, 2020 at 5:24 PM David G. Johnston < david.g.johns...@gmail.com> wrote: > On Tue, Jul 14, 2020 at 8:15 AM Marc Millas > wrote: > >> select id, prenom from prenoms where

Re: some random() clarification needed

2020-07-14 Thread David G. Johnston
On Tue, Jul 14, 2020 at 8:15 AM Marc Millas wrote: > select id, prenom from prenoms where id=ceiling(random()*2582); > > expecting to get, allways, one line. > But its not the case. > around 15% of time I get 0 lines which is already quite strange to me. > but 10% of time, I get a random number

some random() clarification needed

2020-07-14 Thread Marc Millas
Hi, when, in psql, on a postgres 12.3, I write: select ceiling(random()*2582); it does provide the expected answer, ie. a number between 1 and 2582, inclusive. allways. when I decide to use this to get a random row within a table prenoms having 2 columns a id serial, and a prenom varchar, with