cursors

Started by Hector Galiciaover 23 years ago3 messagesgeneral
Jump to latest
#1Hector Galicia
hgaliciac@yahoo.com

Hi
I'm new using postgressql, so my questions is about
the use of cursors. I'm already know how to define,
open and assign into a variable, but what I don't know
is when the cursor is empty. Exist a function that
tells me when the cursor is empty?

thank you
Hector G.

_________________________________________________________
Do You Yahoo!?
Informaci�n de Estados Unidos y Am�rica Latina, en Yahoo! Noticias.
Vis�tanos en http://noticias.espanol.yahoo.com

#2Richard Huxton
dev@archonet.com
In reply to: Hector Galicia (#1)
Re: cursors

On Monday 30 Sep 2002 5:24 pm, Hector Galicia wrote:

Hi
I'm new using postgressql, so my questions is about
the use of cursors. I'm already know how to define,
open and assign into a variable, but what I don't know
is when the cursor is empty. Exist a function that
tells me when the cursor is empty?

If you mean using cursors from plpgsql - check the FOUND variable. To quote
from section 23.7.3.1 of the manuals...

FETCH cursor INTO target;

FETCH retrieves the next row from the cursor into a target, which may be a
row variable, a record variable, or a comma-separated list of simple
variables, just as for SELECT INTO. As with SELECT INTO, the special variable
FOUND may be checked to see whether a row was obtained or not.

HTH, and check Roberto Mello's cookbook at techdocs.postgresql.org

- Richard Huxton

#3Martijn van Oosterhout
kleptog@svana.org
In reply to: Hector Galicia (#1)
Re: cursors

On Mon, Sep 30, 2002 at 11:24:06AM -0500, Hector Galicia wrote:

Hi
I'm new using postgressql, so my questions is about
the use of cursors. I'm already know how to define,
open and assign into a variable, but what I don't know
is when the cursor is empty. Exist a function that
tells me when the cursor is empty?

The way I tell is when you do a FETCH <n> and you get less than <n> results
back.

--
Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/

Show quoted text

There are 10 kinds of people in the world, those that can do binary
arithmetic and those that can't.