<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Forum PostgreSQL - Cursor loop]]></title>
	<link rel="self" href="http://forum.postgresql.org.pl/extern.php?action=feed&amp;tid=1211&amp;type=atom"/>
	<updated>2012-02-21T12:33:28Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.postgresql.org.pl/viewtopic.php?id=1211</id>
		<entry>
			<title type="html"><![CDATA[Odp: Cursor loop]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=3466#p3466"/>
			<content type="html"><![CDATA[a może ktoś wie jak stwerdzić żę korsor jest na ostatnim wierszu?

Np jak bym chciał zrobić warunek że jak jest w ostatnim wierszy ze zbioru to następuję jakieś działanie]]></content>
			<author>
				<name><![CDATA[Rafik83]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=1332</uri>
			</author>
			<updated>2012-02-21T12:33:28Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=3466#p3466</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Odp: Cursor loop]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=3410#p3410"/>
			<content type="html"><![CDATA[ODP jak by ktoś szukał:

[url]http://etutorials.org/SQL/Postgresql/Part+II+Programming+with+PostgreSQL/Chapter+7.+PLpgSQL/Cursors/[/url]

dobrze wytłumaczone]]></content>
			<author>
				<name><![CDATA[Rafik83]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=1332</uri>
			</author>
			<updated>2012-02-06T07:28:53Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=3410#p3410</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Cursor loop]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=3401#p3401"/>
			<content type="html"><![CDATA[Witam,

mam pytanie na temat kursorów w postgres. Mam tabelę z numerami pesel i chce na podstawie peselu wybrać dane z innych tabel.

Aby nie robić mało wydajnej pętli chciałem na tabele gdzie są tylko numery pesel założyć kursor brać pierwszy pesel na postawie jego robić zapytanie do innych tabel, wykonać działania a następnie poprać kolejny pesel.


DECLARE pesel_nr VARCHAR (12)
DECLARE db_cursor CURSOR FOR 
SELECT pesel
from  [TABELA Z PESELAMI]
OPEN db_cursor  
FETCH NEXT FROM db_cursor INTO pesel_nr  -- tak to robiel w innym rozwiazaniu

WHILE @@FETCH_STATUS = 0  
BEGIN  


nazwiskoo :=       select nazwisko 
					from [Tabela z danymi]
                    where nr_pesel = pesel
       
       FETCH NEXT FROM db_cursor INTO pesel_nr  
END  

CLOSE db_cursor  
DEALLOCATE db_cursor


mółbym bez kursorów tylko sama pętla ale to będzie zdecydowanie wolniejsze]]></content>
			<author>
				<name><![CDATA[Rafik83]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=1332</uri>
			</author>
			<updated>2012-02-02T12:27:31Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=3401#p3401</id>
		</entry>
</feed>
