<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Forum PostgreSQL - On Update Cascade]]></title>
	<link rel="self" href="http://forum.postgresql.org.pl/extern.php?action=feed&amp;tid=77&amp;type=atom"/>
	<updated>2008-12-20T21:24:11Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.postgresql.org.pl/viewtopic.php?id=77</id>
		<entry>
			<title type="html"><![CDATA[Odp: On Update Cascade]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=430#p430"/>
			<content type="html"><![CDATA[Hmm nie wiem czy dobrze zrozumiałem.
Zakładasz CONSTRAINTy na idki aby zachować spójność danych w bazie.
Zmieniasz dane w tabeli A i chcesz aby zmiany przeniosły się do B?

Nie lepszy by byłby trigger after update na tabeli a,ktory zrobi update na tabeli b?]]></content>
			<author>
				<name><![CDATA[psocha]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=519</uri>
			</author>
			<updated>2008-12-20T21:24:11Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=430#p430</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[On Update Cascade]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=267#p267"/>
			<content type="html"><![CDATA[Witam. mÓj problem dotyczy właśnie ON UPDATE CASCADE otóż:
mam sobie dwie tabele A i B
w tabeli a trzymam pewne wartości a w B tymczasowe wartości z tabeli A i teraz chodzi o to że jeżeli założe ograniczenie na tabele B -> ON UPDATE CASCADE ON DELETE CASCADE to po usunięciu pozycji z tabeli A usuwa się automatycznie pozycja z tabeli B i o to mi właśnie chodziło ale kiedy zmieniam dane w tabeli A nie automatycznie powinny zmienić się w tabeli B i tu jest mój problem gdyż zmieniam dane w A a w B pozostają takie jakie były na początku dodania do B.

Może zagmatwałem ale chodzi o to że ON UPDATE CASCADE mi nie działa chyba że źle coś robię.
moje dwie tabele to:
CREATE TABLE kartoteki.A(
id_tow bigserial not null, 
id_index int not null, 
id_klient int not null, 
id_towaru int not null, 
flag boolean not null, 
nazwa_tow varchar(128) not null, 
nazwa_fiskalna varchar(16) null,
nr_fvz varchar(32) not null, 
id_jm integer not null, 
id_typ text not null, 
ilosc float not null, 
cena float not null, 
cena_sprz float not null, 
sn varchar(128) null, 
created_by integer null, 
modified_by integer null, 
created_date date null, 
modified_date date null, 
opis text null, 
gwarancja varchar(64) null, 
vat varchar(16) not null, 
tabela text not null, 
PRIMARY KEY(id_tow), 
CONSTRAINT id_klient FOREIGN KEY (id_klient) REFERENCES kartoteki.zestawy_skladane (id) ON UPDATE NO ACTION ON DELETE NO ACTION, CONSTRAINT id_index FOREIGN KEY (id_index) REFERENCES kartoteki.lista_zestawu (id) ON UPDATE NO ACTION ON DELETE NO ACTION, CONSTRAINT id_jm FOREIGN KEY (id_jm) REFERENCES kartoteki.jednostki_miar (id) ON UPDATE NO ACTION ON DELETE NO ACTION, CONSTRAINT id_typ FOREIGN KEY (id_typ) REFERENCES kartoteki.typ_towarow (nazwa_typu) ON UPDATE NO ACTION ON DELETE NO ACTION);

CREATE TABLE tmp.B(
id bigserial not null, 
id_tow_ref bigint not null,
 id_towaru bigint null, 
flag boolean not null, 
dodal integer not null, 
nazwa varchar(128) not null, 
nazwa_fiskalna varchar(16) null, 
nr_fvz varchar(32) null, 
id_jm integer not null,
id_typ text null, 
ilosc float not null, 
cena float not null, 
cena_sprz float not null, 
sn varchar(128) null, 
created_by integer null, 
modified_by integer null, 
created_date date null, 
modified_date date null, 
opis text null, 
gwarancja varchar(64) null, 
vat varchar(16) not null, 
tabela text null, 
PRIMARY KEY(id), UNIQUE(id_tow_ref), 
[b]CONSTRAINT id_tow_referencja FOREIGN KEY (id_tow_ref) REFERENCES kartoteki.towary_dla_zestawy_skladane (id_tow) ON UPDATE CASCADE ON DELETE CASCADE[/b]);

Nie wiem dlaczego to nie działa.]]></content>
			<author>
				<name><![CDATA[rafko]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=8</uri>
			</author>
			<updated>2008-08-29T11:52:06Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=267#p267</id>
		</entry>
</feed>
