Re: [GENERAL] PL/pgSQL: SELECT INTO only if result count = 1

2011-08-28 Thread Tarlika Elisabeth Schmitz
On Sat, 27 Aug 2011 18:36:14 -0400 Tom Lane wrote: >Tarlika Elisabeth Schmitz writes: >> SELECT INTO >> country_id, region_id, town_id >> country_fk, region_fk, id >> FROM town >> WHERE ...; > >> GET DIAGNOSTICS cnt = ROW_COUNT; >> RAISE DEBUG 'COUNT %', cnt; > >> always returns 1 > >Yeah. B

Re: [GENERAL] PL/pgSQL: SELECT INTO only if result count = 1

2011-08-27 Thread Tom Lane
Tarlika Elisabeth Schmitz writes: > SELECT INTO > country_id, region_id, town_id > country_fk, region_fk, id > FROM town > WHERE ...; > GET DIAGNOSTICS cnt = ROW_COUNT; > RAISE DEBUG 'COUNT %', cnt; > always returns 1 Yeah. By default, SELECT INTO just fetches one row and stops; it doesn't

Re: [GENERAL] PL/pgSQL: SELECT INTO only if result count = 1

2011-08-27 Thread Tarlika Elisabeth Schmitz
On Sat, 27 Aug 2011 18:45:42 -0300 Osvaldo Kussama wrote: >2011/8/27, Tarlika Elisabeth Schmitz >: >> Hello, >> >> In a PL/pgSQL trigger function, I try to select a record from table >> "town" below. >> >> I am only interested in the result if the returned result set >> contains exactly one resul

[GENERAL] PL/pgSQL: SELECT INTO only if result count = 1

2011-08-27 Thread Tarlika Elisabeth Schmitz
Hello, In a PL/pgSQL trigger function, I try to select a record from table "town" below. I am only interested in the result if the returned result set contains exactly one result. If there is more than one result, I want to log the fact. EXAMPLE pseudo code select country_fk, region_fk, id fro