Re: Questions on Cursors in PostgreSQL

Dmitry Igrishin <[email protected]> Tue, 27 Jun 2017 20:53:08 +0300
Newsgroups gmane.comp.db.postgresql.interfaces
Message-ID <CAAfz9KOYXULgqb-YChRYCY6c+i6V+MUE1xSoNzBiJhNO6KmaJg@mail.gmail.com>
--94eb2c0b08008d63e30552f4bd7e
Content-Type: text/plain; charset="UTF-8"

2017-06-27 20:07 GMT+03:00 Wei Shan <[email protected]>:

> Hi all,
>
> I have some questions on PostgreSQL cursors (not PL/pgSQL but the libpq
> implementation):
>
>
>    1. What happens when my cursor hit the end of the table? Does it close
>    automatically? I suppose if I declare it as a SCROLLABLE cursor, it should
>    not close at all.
>
> The lifetime of cursors created by the DECLARE ... SQL command longs until
the end of the session, or until it explicitly closed by either CLOSE ...
or DISCARD SQL commands.

>
>    1. If I have declared a cursor and the session got disconnected, can I
>    reattach back to the cursor if I know the cursor name? I believe this is
>    not possible but I'm not very sure.
>
> When session ends all cursors are deallocated automatically. You should
open the new cursor on reconnect.

--94eb2c0b08008d63e30552f4bd7e
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><div class=3D"gmail_quo=
te">2017-06-27 20:07 GMT+03:00 Wei Shan <span dir=3D"ltr">&lt;<a href=3D"ma=
ilto:[email protected]" target=3D"_blank">[email protected]</a>&gt;=
</span>:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;bo=
rder-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">Hi all,<div><br=
></div><div>I have some questions on PostgreSQL cursors (not PL/pgSQL but t=
he libpq implementation):=C2=A0</div><div><br></div><div><ol><li>What happe=
ns when my cursor hit the end of the table? Does it close automatically? I =
suppose if I declare it as a SCROLLABLE cursor, it should not close at all.=
</li></ol></div></div></blockquote><div>The lifetime of cursors created by =
the DECLARE ... SQL command longs until the end of the session, or until it=
 explicitly closed by either CLOSE ... or DISCARD SQL commands.</div><block=
quote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc=
 solid;padding-left:1ex"><div dir=3D"ltr"><div><ol><li>If I have declared a=
 cursor and the session got disconnected, can I reattach back to the cursor=
 if I know the cursor name? I believe this is not possible but I&#39;m not =
very sure.</li></ol></div></div></blockquote><div>When session ends all cur=
sors are deallocated automatically. You should open the new cursor on recon=
nect.</div></div></div></div>

--94eb2c0b08008d63e30552f4bd7e--