<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Forum PostgreSQL - Reguły i rekurencja]]></title>
		<link>https://forum.postgresql.org.pl/viewtopic.php?id=535</link>
		<description><![CDATA[Najświeższe odpowiedzi w Reguły i rekurencja.]]></description>
		<lastBuildDate>Wed, 26 Jan 2011 19:31:20 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Odp: Reguły i rekurencja]]></title>
			<link>https://forum.postgresql.org.pl/viewtopic.php?pid=2370#p2370</link>
			<description><![CDATA[Dzięki. Potestuję triggery.]]></description>
			<author><![CDATA[dummy@example.com (Rayo)]]></author>
			<pubDate>Wed, 26 Jan 2011 19:31:20 +0000</pubDate>
			<guid>https://forum.postgresql.org.pl/viewtopic.php?pid=2370#p2370</guid>
		</item>
		<item>
			<title><![CDATA[Odp: Reguły i rekurencja]]></title>
			<link>https://forum.postgresql.org.pl/viewtopic.php?pid=2369#p2369</link>
			<description><![CDATA[No niestety z tymi regułami to nie jest tak prosto. Ogólnie raczej należy się ich wystrzegać.
W tym przypadku musiałbyś do update dodać warunek
[code]
WHERE <columna>=NEW.<columna>
[/code]
ale to musisz mieć w tabeli coś co jednoznacznie identyfikuje kolumny, jakiś klucz (może u Ciebie to jest gid).
A i tak nie mam pewności czy to zawsze zadziała, takie są reguły :).]]></description>
			<author><![CDATA[dummy@example.com (rski)]]></author>
			<pubDate>Wed, 26 Jan 2011 19:19:30 +0000</pubDate>
			<guid>https://forum.postgresql.org.pl/viewtopic.php?pid=2369#p2369</guid>
		</item>
		<item>
			<title><![CDATA[Odp: Reguły i rekurencja]]></title>
			<link>https://forum.postgresql.org.pl/viewtopic.php?pid=2368#p2368</link>
			<description><![CDATA[[quote=rski]Zamień to na triggera before insert[/quote]

OK spróbuję.
Próbowałem też zostawić oryginalnego INSERTA i dodać regułę

REATE OR REPLACE RULE ins2 AS
    ON INSERT TO test004 DO  UPDATE test004 SET "Data_wprow" = now();

ale uzupełnia mi wszystkie wiersze w kolumnie "Data_wprow", a nie tylko ten "insertowany".]]></description>
			<author><![CDATA[dummy@example.com (Rayo)]]></author>
			<pubDate>Wed, 26 Jan 2011 19:14:38 +0000</pubDate>
			<guid>https://forum.postgresql.org.pl/viewtopic.php?pid=2368#p2368</guid>
		</item>
		<item>
			<title><![CDATA[Odp: Reguły i rekurencja]]></title>
			<link>https://forum.postgresql.org.pl/viewtopic.php?pid=2367#p2367</link>
			<description><![CDATA[Zamień to na triggera before insert]]></description>
			<author><![CDATA[dummy@example.com (rski)]]></author>
			<pubDate>Wed, 26 Jan 2011 18:55:49 +0000</pubDate>
			<guid>https://forum.postgresql.org.pl/viewtopic.php?pid=2367#p2367</guid>
		</item>
		<item>
			<title><![CDATA[Reguły i rekurencja]]></title>
			<link>https://forum.postgresql.org.pl/viewtopic.php?pid=2366#p2366</link>
			<description><![CDATA[Utworzyłem regułę do tabeli, która zastępuje INSERT

CREATE OR REPLACE RULE ins AS
    ON INSERT TO test004 DO INSTEAD  INSERT INTO test004 (gid, "NazwaCiagu", "NazwaLinii", the_geom, "Wprowadzil", "Data_wprow") 
  VALUES (new.gid, new."NazwaCiagu", new."NazwaLinii", new.the_geom, "current_user"(), now());

Jednak nie da się z niej skorzystać z powodu wywołania rekurencyjnego - jeden INSERT powoduje wywołanie następnego itd.

Jak to ominąć?]]></description>
			<author><![CDATA[dummy@example.com (Rayo)]]></author>
			<pubDate>Wed, 26 Jan 2011 18:49:20 +0000</pubDate>
			<guid>https://forum.postgresql.org.pl/viewtopic.php?pid=2366#p2366</guid>
		</item>
	</channel>
</rss>
