Re: [GENERAL] “Loop” in plpgsql Function - PostgreSQL 9.2

From: "drum(dot)lucas(at)gmail(dot)com" <drum(dot)lucas(at)gmail(dot)com>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: [GENERAL] “Loop” in plpgsql Function - PostgreSQL 9.2
Date: 2016-01-18 22:34:33
Message-ID: CAE_gQfUityfN=c_eWEvOkosLEA3OqJsA=pDe1oDppLvGeUi8DQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

>
> It is customary to restrict emails to a single list or at least make
> others aware when you do have a legitmate need to cross-post.
>
> Specifically your post on -admin <“Break” in plpgsql Function - PostgreSQL
> 9.2>
>
> Yes, it didn't belong on -admin in the first place but posting it here
> with a different title and not indicating on either thread that the other
> exists and/or is the valid one just makes it harder for others to follow
> along.
>
>
Sorry about that. It wasn't on purpose... It won't happen again.

>
> As for your general question I try to approach this problem in the
> following manner:
>
> SELECT however many of something that you need (FOR UPDATE)
> UPDATE those selected to indicate that they have been seen
> PROCESS them as needed
> ​repeat step 1 until it returns no records
>
> ​It doesn't always work - and given a sufficiently large number of records
> it may be unadvisable - but it is set-oriented which is generally a plus in
> SQL.
>
> The other way to assign batches is to use the integer modulus operator
> (e.g., 10 % 3 = 1 : read 3 *remainder of 1*) or integer division (10 / 3
> = 3) to derive the batch number based upon an attribute of the data itself
> as opposed to its order of appearance in a result set.
>
> David J.
>
>
> ​
>
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message dinesh kumar 2016-01-18 22:44:07 Re: [GENERAL] “Loop” in plpgsql Function - PostgreSQL 9.2
Previous Message David G. Johnston 2016-01-18 22:29:31 Re: [GENERAL] “Loop” in plpgsql Function - PostgreSQL 9.2