Re: Cursor bug?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Cursor bug?
Дата
Msg-id 15362.1105653486@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Cursor bug?  ("Mike G." <mike@thegodshalls.com>)
Ответы Re: Cursor bug?  ("Mike G." <mike@thegodshalls.com>)
Список pgsql-general
"Mike G." <mike@thegodshalls.com> writes:
> I have a function that reads through one table via a cursor to make updates to a different table.  There is a row in
thistable with a column that has a null value.  The following row, in that same column, is not null.   
> When the cursor loops through the table it seems to be treating the non null row as being null.  The fetch should be
insertingthe new non value into the variable but doesn't appear to be. 

You did "select count(name)", which counts the number of non-null
occurrences of "name", ie 2.  So the loop stops after two iterations,
and never gets to the last row.

I'd lose the count() step entirely and have the loop be driven solely by
the cursor.  Actually, why use a cursor at all, as opposed to a FOR IN
SELECT loop?

            regards, tom lane

В списке pgsql-general по дате отправления:

Предыдущее
От: "Frank D. Engel, Jr."
Дата:
Сообщение: Re: Adding UNIQUE constraint on NULL column
Следующее
От: "Mike G."
Дата:
Сообщение: Re: Cursor bug?