Re: [GENERAL] A question about PL/pgSQL DECLAREd variable behavior

2015-10-23 Thread Jim Nasby
On 10/22/15 8:52 PM, Dane Foster wrote: It just occurred to me that another option, for my specific example, would be to record/cache FOUND instead of testing the RECORD variable for its NULLness. Unless of course assigning FOUND to a variable is a pass-by-reference assignment, which in the

Re: [GENERAL] A question about PL/pgSQL DECLAREd variable behavior

2015-10-23 Thread Pavel Stehule
2015-10-23 18:05 GMT+02:00 Jim Nasby : > On 10/22/15 8:52 PM, Dane Foster wrote: > >> It just occurred to me that another option, for my specific example, >> would be to record/cache FOUND instead of testing the RECORD variable >> for its NULLness. Unless of course

Re: [GENERAL] A question about PL/pgSQL DECLAREd variable behavior

2015-10-22 Thread Jim Nasby
On 10/21/15 9:32 PM, Dane Foster wrote: "If STRICT is not specified in the INTO clause, then target will be set to the first row returned by the query, or to nulls if the query returned no rows." ​Foot removed from mouth. Note however that there's some unexpected things when

Re: [GENERAL] A question about PL/pgSQL DECLAREd variable behavior

2015-10-22 Thread Dane Foster
On Thu, Oct 22, 2015 at 2:00 PM, Jim Nasby wrote: > On 10/21/15 9:32 PM, Dane Foster wrote: > >> "If STRICT is not specified in the INTO clause, then target will be >> set to the first row returned by the query, or to nulls if the query >> returned no rows."

Re: [GENERAL] A question about PL/pgSQL DECLAREd variable behavior

2015-10-22 Thread Thomas Munro
On Fri, Oct 23, 2015 at 12:33 PM, Dane Foster wrote: > On Thu, Oct 22, 2015 at 6:54 PM, Thomas Munro > wrote: >> >> On Fri, Oct 23, 2015 at 10:27 AM, Dane Foster wrote: >> > On Thu, Oct 22, 2015 at 2:00 PM, Jim Nasby

Re: [GENERAL] A question about PL/pgSQL DECLAREd variable behavior

2015-10-22 Thread Dane Foster
On Thu, Oct 22, 2015 at 6:54 PM, Thomas Munro wrote: > On Fri, Oct 23, 2015 at 10:27 AM, Dane Foster wrote: > > On Thu, Oct 22, 2015 at 2:00 PM, Jim Nasby > wrote: > >> On 10/21/15 9:32 PM, Dane Foster wrote: > >>>

Re: [GENERAL] A question about PL/pgSQL DECLAREd variable behavior

2015-10-22 Thread Thomas Munro
On Fri, Oct 23, 2015 at 10:27 AM, Dane Foster wrote: > On Thu, Oct 22, 2015 at 2:00 PM, Jim Nasby wrote: >> On 10/21/15 9:32 PM, Dane Foster wrote: >>> >>> "If STRICT is not specified in the INTO clause, then target will be >>> set to the

Re: [GENERAL] A question about PL/pgSQL DECLAREd variable behavior

2015-10-22 Thread Dane Foster
On Thu, Oct 22, 2015 at 9:15 PM, Thomas Munro wrote: > On Fri, Oct 23, 2015 at 12:33 PM, Dane Foster wrote: > > On Thu, Oct 22, 2015 at 6:54 PM, Thomas Munro > > wrote: > >> > >> On Fri, Oct 23, 2015 at 10:27

[GENERAL] A question about PL/pgSQL DECLAREd variable behavior

2015-10-21 Thread Dane Foster
I wrote the following simple function to try to learn what happens to a DECLAREd variable whose assignment comes from an INTO statement where the query being executed does not return a result. CREATE OR REPLACE FUNCTION _test() RETURNS BOOLEAN AS $$ DECLARE r RECORD; BEGIN SELECT 1 AS one INTO r

Re: [GENERAL] A question about PL/pgSQL DECLAREd variable behavior

2015-10-21 Thread Thomas Munro
On Thu, Oct 22, 2015 at 2:48 PM, Dane Foster wrote: > I wrote the following simple function to try to learn what happens to a > DECLAREd variable whose assignment comes from an INTO statement where the > query being executed does not return a result. > > CREATE OR REPLACE

Re: [GENERAL] A question about PL/pgSQL DECLAREd variable behavior

2015-10-21 Thread Dane Foster
On Wed, Oct 21, 2015 at 10:23 PM, Thomas Munro < thomas.mu...@enterprisedb.com> wrote: > On Thu, Oct 22, 2015 at 2:48 PM, Dane Foster wrote: > > I wrote the following simple function to try to learn what happens to a > > DECLAREd variable whose assignment comes from an INTO

Re: [GENERAL] A question about PL/pgSQL

2000-10-30 Thread K Parker
Doesn't the following allow a race condition? declare foo record; begin select into foo * from overview... if not found insert... else ... end if; end; ISTM 2 or more clients could attempt to insert the same row, based on the select failing, if all were issued at the same time. I've

Re: [GENERAL] A question about PL/pgSQL

2000-10-28 Thread Igor Roboul
On Fri, Oct 27, 2000 at 02:32:28PM -0700, Warren Vanichuk wrote: Greetings. I am writting up a function in PL/pgSQL to automate a couple of multi-table updates, and I have a question. I need to check to see if the data is already in the database, and if it is, perform and update, or if

[GENERAL] A question about PL/pgSQL

2000-10-27 Thread Warren Vanichuk
Greetings. I am writting up a function in PL/pgSQL to automate a couple of multi-table updates, and I have a question. I need to check to see if the data is already in the database, and if it is, perform and update, or if it's not, perform an insert. The lookup is against a primary key, so I

Re: [GENERAL] A question about PL/pgSQL

2000-10-27 Thread Alex Pilosov
On Fri, 27 Oct 2000, Warren Vanichuk wrote: Greetings. I am writting up a function in PL/pgSQL to automate a couple of multi-table updates, and I have a question. I need to check to see if the data is already in the database, and if it is, perform and update, or if it's not, perform