<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://sqle.ru/index.php?action=history&amp;feed=atom&amp;title=PostgreSQL%2FCursor%2FDeclare_Cursor</id>
		<title>PostgreSQL/Cursor/Declare Cursor - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://sqle.ru/index.php?action=history&amp;feed=atom&amp;title=PostgreSQL%2FCursor%2FDeclare_Cursor"/>
		<link rel="alternate" type="text/html" href="http://sqle.ru/index.php?title=PostgreSQL/Cursor/Declare_Cursor&amp;action=history"/>
		<updated>2026-04-06T12:17:12Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://sqle.ru/index.php?title=PostgreSQL/Cursor/Declare_Cursor&amp;diff=4464&amp;oldid=prev</id>
		<title> в 13:45, 26 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://sqle.ru/index.php?title=PostgreSQL/Cursor/Declare_Cursor&amp;diff=4464&amp;oldid=prev"/>
				<updated>2010-05-26T13:45:56Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 13:45, 26 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://sqle.ru/index.php?title=PostgreSQL/Cursor/Declare_Cursor&amp;diff=4465&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://sqle.ru/index.php?title=PostgreSQL/Cursor/Declare_Cursor&amp;diff=4465&amp;oldid=prev"/>
				<updated>2010-05-26T10:13:46Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Opens a transaction, declares the cur_publishers cursor, and closes it==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;sql&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
postgres=# CREATE TABLE &amp;quot;publishers&amp;quot; (&lt;br /&gt;
postgres(#      &amp;quot;id&amp;quot; integer NOT NULL,&lt;br /&gt;
postgres(#      &amp;quot;name&amp;quot; text,&lt;br /&gt;
postgres(#      &amp;quot;address&amp;quot; text,&lt;br /&gt;
postgres(#      Constraint &amp;quot;publishers_pkey&amp;quot; Primary Key (&amp;quot;id&amp;quot;)&lt;br /&gt;
postgres(# );&lt;br /&gt;
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index &amp;quot;publishers_pkey&amp;quot; for table &amp;quot;publishers&amp;quot;&lt;br /&gt;
CREATE TABLE&lt;br /&gt;
postgres=#&lt;br /&gt;
postgres=#&lt;br /&gt;
postgres=# insert into publishers values(150, &amp;quot;Can Press&amp;quot;,  &amp;quot;29 Ave. Toronto, ON&amp;quot;);&lt;br /&gt;
INSERT 0 1&lt;br /&gt;
postgres=# insert into publishers values(91,  &amp;quot;Henry Inc.&amp;quot;, &amp;quot;115 Street New York, NY&amp;quot;);&lt;br /&gt;
INSERT 0 1&lt;br /&gt;
postgres=# insert into publishers values(113, &amp;quot;O Inc.&amp;quot;,     &amp;quot;101 St, Sebastopol, CA&amp;quot;);&lt;br /&gt;
INSERT 0 1&lt;br /&gt;
postgres=# insert into publishers values(62,  &amp;quot;W Pubs&amp;quot;,     &amp;quot;1515, New York&amp;quot;);&lt;br /&gt;
INSERT 0 1&lt;br /&gt;
postgres=# insert into publishers values(105, &amp;quot;N Press&amp;quot;,    &amp;quot;19 W, New York&amp;quot;);&lt;br /&gt;
INSERT 0 1&lt;br /&gt;
postgres=# insert into publishers values(99,  &amp;quot;A Inc&amp;quot;,      &amp;quot;375 St, New York&amp;quot;);&lt;br /&gt;
INSERT 0 1&lt;br /&gt;
postgres=# insert into publishers values(101, &amp;quot;Z Inc&amp;quot;,      &amp;quot;375 Ave, New York&amp;quot;);&lt;br /&gt;
INSERT 0 1&lt;br /&gt;
postgres=# insert into publishers values(163, &amp;quot;M Press&amp;quot;,    &amp;quot;PO Box 1215&amp;quot;);&lt;br /&gt;
INSERT 0 1&lt;br /&gt;
postgres=# insert into publishers values(171, &amp;quot;B&amp;quot;,          &amp;quot;16 W. 18th St. New York&amp;quot;);&lt;br /&gt;
INSERT 0 1&lt;br /&gt;
postgres=# insert into publishers values(102, &amp;quot;P Inc&amp;quot;,      &amp;quot;375 Hudson St, New York&amp;quot;);&lt;br /&gt;
INSERT 0 1&lt;br /&gt;
postgres=# insert into publishers values(75,  &amp;quot;D Inc&amp;quot;,      &amp;quot;1540 Broadway, New York&amp;quot;);&lt;br /&gt;
INSERT 0 1&lt;br /&gt;
postgres=# insert into publishers values(65,  &amp;quot;H Pubs&amp;quot;,     &amp;quot;10 E 53rd St, New York&amp;quot;);&lt;br /&gt;
INSERT 0 1&lt;br /&gt;
postgres=# insert into publishers values(59,  &amp;quot;R Inc&amp;quot;,      &amp;quot;1540 Broadway, New York&amp;quot;);&lt;br /&gt;
INSERT 0 1&lt;br /&gt;
postgres=#&lt;br /&gt;
postgres=# select * from publishers;&lt;br /&gt;
 id  |    name    |         address&lt;br /&gt;
-----+------------+-------------------------&lt;br /&gt;
 150 | Can Press  | 29 Ave. Toronto, ON&lt;br /&gt;
  91 | Henry Inc. | 115 Street New York, NY&lt;br /&gt;
 113 | O Inc.     | 101 St, Sebastopol, CA&lt;br /&gt;
  62 | W Pubs     | 1515, New York&lt;br /&gt;
 105 | N Press    | 19 W, New York&lt;br /&gt;
  99 | A Inc      | 375 St, New York&lt;br /&gt;
 101 | Z Inc      | 375 Ave, New York&lt;br /&gt;
 163 | M Press    | PO Box 1215&lt;br /&gt;
 171 | B          | 16 W. 18th St. New York&lt;br /&gt;
 102 | P Inc      | 375 Hudson St, New York&lt;br /&gt;
  75 | D Inc      | 1540 Broadway, New York&lt;br /&gt;
  65 | H Pubs     | 10 E 53rd St, New York&lt;br /&gt;
  59 | R Inc      | 1540 Broadway, New York&lt;br /&gt;
(13 rows)&lt;br /&gt;
postgres=#&lt;br /&gt;
postgres=#&lt;br /&gt;
postgres=# --Opens a transaction, declares the cur_publishers cursor, and closes it:&lt;br /&gt;
postgres=#&lt;br /&gt;
postgres=# BEGIN;&lt;br /&gt;
BEGIN&lt;br /&gt;
postgres=# DECLARE cur_publishers CURSOR FOR SELECT * FROM publishers;&lt;br /&gt;
DECLARE CURSOR&lt;br /&gt;
postgres=# CLOSE cur_publishers;&lt;br /&gt;
CLOSE CURSOR&lt;br /&gt;
postgres=#&lt;br /&gt;
postgres=# drop table publishers;&lt;br /&gt;
DROP TABLE&lt;br /&gt;
postgres=#&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Using cursor in transaction==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;sql&amp;quot;&amp;gt;&lt;br /&gt;
postgres=#&lt;br /&gt;
postgres=# CREATE TABLE employee (&lt;br /&gt;
postgres(#     ID         int,&lt;br /&gt;
postgres(#     name       varchar(10),&lt;br /&gt;
postgres(#     salary     real,&lt;br /&gt;
postgres(#     start_date date,&lt;br /&gt;
postgres(#     city       varchar(10),&lt;br /&gt;
postgres(#     region     char(1)&lt;br /&gt;
postgres(# );&lt;br /&gt;
CREATE TABLE&lt;br /&gt;
postgres=#&lt;br /&gt;
postgres=# insert into employee (ID, name,    salary, start_date, city,       region)&lt;br /&gt;
postgres-#               values (1,  &amp;quot;Jason&amp;quot;, 40420,  &amp;quot;02/01/94&amp;quot;, &amp;quot;New York&amp;quot;, &amp;quot;W&amp;quot;);&lt;br /&gt;
INSERT 0 1&lt;br /&gt;
postgres=# insert into employee (ID, name,    salary, start_date, city,       region)&lt;br /&gt;
postgres-#               values (2,  &amp;quot;Robert&amp;quot;,14420,  &amp;quot;01/02/95&amp;quot;, &amp;quot;Vancouver&amp;quot;,&amp;quot;N&amp;quot;);&lt;br /&gt;
INSERT 0 1&lt;br /&gt;
postgres=# insert into employee (ID, name,    salary, start_date, city,       region)&lt;br /&gt;
postgres-#               values (3,  &amp;quot;Celia&amp;quot;, 24020,  &amp;quot;12/03/96&amp;quot;, &amp;quot;Toronto&amp;quot;,  &amp;quot;W&amp;quot;);&lt;br /&gt;
INSERT 0 1&lt;br /&gt;
postgres=# insert into employee (ID, name,    salary, start_date, city,       region)&lt;br /&gt;
postgres-#               values (4,  &amp;quot;Linda&amp;quot;, 40620,  &amp;quot;11/04/97&amp;quot;, &amp;quot;New York&amp;quot;, &amp;quot;N&amp;quot;);&lt;br /&gt;
INSERT 0 1&lt;br /&gt;
postgres=# insert into employee (ID, name,    salary, start_date, city,       region)&lt;br /&gt;
postgres-#               values (5,  &amp;quot;David&amp;quot;, 80026,  &amp;quot;10/05/98&amp;quot;, &amp;quot;Vancouver&amp;quot;,&amp;quot;W&amp;quot;);&lt;br /&gt;
INSERT 0 1&lt;br /&gt;
postgres=# insert into employee (ID, name,    salary, start_date, city,       region)&lt;br /&gt;
postgres-#               values (6,  &amp;quot;James&amp;quot;, 70060,  &amp;quot;09/06/99&amp;quot;, &amp;quot;Toronto&amp;quot;,  &amp;quot;N&amp;quot;);&lt;br /&gt;
INSERT 0 1&lt;br /&gt;
postgres=# insert into employee (ID, name,    salary, start_date, city,       region)&lt;br /&gt;
postgres-#               values (7,  &amp;quot;Alison&amp;quot;,90620,  &amp;quot;08/07/00&amp;quot;, &amp;quot;New York&amp;quot;, &amp;quot;W&amp;quot;);&lt;br /&gt;
INSERT 0 1&lt;br /&gt;
postgres=# insert into employee (ID, name,    salary, start_date, city,       region)&lt;br /&gt;
postgres-#               values (8,  &amp;quot;Chris&amp;quot;, 26020,  &amp;quot;07/08/01&amp;quot;, &amp;quot;Vancouver&amp;quot;,&amp;quot;N&amp;quot;);&lt;br /&gt;
INSERT 0 1&lt;br /&gt;
postgres=# insert into employee (ID, name,    salary, start_date, city,       region)&lt;br /&gt;
postgres-#               values (9,  &amp;quot;Mary&amp;quot;,  60020,  &amp;quot;06/09/02&amp;quot;, &amp;quot;Toronto&amp;quot;,  &amp;quot;W&amp;quot;);&lt;br /&gt;
INSERT 0 1&lt;br /&gt;
postgres=#&lt;br /&gt;
postgres=# select * from employee;&lt;br /&gt;
 id |  name  | salary | start_date |   city    | region&lt;br /&gt;
----+--------+--------+------------+-----------+--------&lt;br /&gt;
  1 | Jason  |  40420 | 1994-02-01 | New York  | W&lt;br /&gt;
  2 | Robert |  14420 | 1995-01-02 | Vancouver | N&lt;br /&gt;
  3 | Celia  |  24020 | 1996-12-03 | Toronto   | W&lt;br /&gt;
  4 | Linda  |  40620 | 1997-11-04 | New York  | N&lt;br /&gt;
  5 | David  |  80026 | 1998-10-05 | Vancouver | W&lt;br /&gt;
  6 | James  |  70060 | 1999-09-06 | Toronto   | N&lt;br /&gt;
  7 | Alison |  90620 | 2000-08-07 | New York  | W&lt;br /&gt;
  8 | Chris  |  26020 | 2001-07-08 | Vancouver | N&lt;br /&gt;
  9 | Mary   |  60020 | 2002-06-09 | Toronto   | W&lt;br /&gt;
(9 rows)&lt;br /&gt;
postgres=#&lt;br /&gt;
postgres=#&lt;br /&gt;
postgres=# BEGIN;&lt;br /&gt;
BEGIN&lt;br /&gt;
postgres=# DECLARE cur_employee CURSOR FOR SELECT id, name FROM employee;&lt;br /&gt;
DECLARE CURSOR&lt;br /&gt;
postgres=# FETCH FORWARD 2 IN cur_employee;&lt;br /&gt;
 id |  name&lt;br /&gt;
----+--------&lt;br /&gt;
  1 | Jason&lt;br /&gt;
  2 | Robert&lt;br /&gt;
(2 rows)&lt;br /&gt;
postgres=# -- Fetch backwards in the cur_employee cursor:&lt;br /&gt;
postgres=#&lt;br /&gt;
postgres=# FETCH BACKWARD 3 IN cur_employee;&lt;br /&gt;
 id | name&lt;br /&gt;
----+-------&lt;br /&gt;
  1 | Jason&lt;br /&gt;
(1 row)&lt;br /&gt;
postgres=#&lt;br /&gt;
postgres=# END;&lt;br /&gt;
COMMIT&lt;br /&gt;
postgres=#&lt;br /&gt;
postgres=#&lt;br /&gt;
postgres=#&lt;br /&gt;
postgres=# drop table employee;&lt;br /&gt;
DROP TABLE&lt;br /&gt;
postgres=#&lt;br /&gt;
postgres=#&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>