Re: Questions on Cursors in PostgreSQL
Wei Shan <[email protected]> Tue, 4 Jul 2017 09:53:08 +0100
| Newsgroups | gmane.comp.db.postgresql.interfaces |
|---|---|
| Message-ID | <CAFe9ZTo-wOVKjD0bgkEE=CS3N=qDpk60OE7VuLOng9-GmaMS1Q@mail.gmail.com> |
--94eb2c1b6ec442c64805537a03d7 Content-Type: text/plain; charset="UTF-8" Thanks a lot! On 27 Jun 2017 18:53, "Dmitry Igrishin" <[email protected]> wrote: 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. --94eb2c1b6ec442c64805537a03d7 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"auto"><div>Thanks a lot!<div dir=3D"auto"><br></div><div dir=3D= "auto"><br></div><br><div class=3D"gmail_extra"><br><div class=3D"gmail_quo= te">On 27 Jun 2017 18:53, "Dmitry Igrishin" <<a href=3D"mailto= :[email protected]">[email protected]</a>> wrote:<br type=3D"attribution= "><blockquote class=3D"quote" style=3D"margin:0 0 0 .8ex;border-left:1px #c= cc solid;padding-left:1ex"><div dir=3D"ltr"><br><div class=3D"gmail_extra">= <br><div class=3D"gmail_quote"><div class=3D"quoted-text">2017-06-27 20:07 = GMT+03:00 Wei Shan <span dir=3D"ltr"><<a href=3D"mailto:weishan.ang@gmai= l.com" target=3D"_blank">[email protected]</a>></span>:<br><blockquo= te class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc so= lid;padding-left:1ex"><div dir=3D"ltr">Hi all,<div><br></div><div>I have so= me questions on PostgreSQL cursors (not PL/pgSQL but the libpq implementati= on):=C2=A0</div><div><br></div><div><ol><li>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.</li></ol></div></div= ></blockquote></div><div>The lifetime of cursors created by the DECLARE ...= SQL command longs until the end of the session, or until it explicitly clo= sed by either CLOSE ... or DISCARD SQL commands.</div><div class=3D"quoted-= text"><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-l= eft:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div><ol><li>If I hav= e declared a cursor and the session got disconnected, can I reattach back t= o the cursor if I know the cursor name? I believe this is not possible but = I'm not very sure.</li></ol></div></div></blockquote></div><div>When se= ssion ends all cursors are deallocated automatically. You should open the n= ew cursor on reconnect.</div></div></div></div> </blockquote></div><br></div></div></div> --94eb2c1b6ec442c64805537a03d7--