SELECT INTO returning more than one row
SELECT INTO returning more than one row
От:
Zac <zaccheob@inwind.it>
Дата:
Hi. I have this problem in a plpgsql function: SELECT INTO myvar col FROM table WHERE ...; IF THENdo something ELSE IF THENdo something else ELSEdo other things If I know that myvar IS NULL OR GET DIAGNOSTICS ROW_COUNT is zero. Is there a way to know if the query returned more than one row? In Oracle PL/SQL I can catch the TOO_MANY_ROWS exception but in Postgres I found no way for doing it: - myvar is correctly valued with the first occurrence of the result - FOUND is TRUE - GET DIAGNOSTICS ROW_COUNT is 1 (it counts only fetched rows) I tried to use a cursor but the only way to know how many rows it returned is to fetch them all. (And I don't like this solution) Thanks in advance.