Subject | RE: [firebird-support] synchronized update doesn't work properly |
---|---|
Author | Svein Erling Tysvær |
Post date | 2008-01-16T10:35:14Z |
Without a WHERE clause you update all rows. Change to:
update tab1 t1
set email =
(
select t2.email from tab2 t2 where t1.customer_id = t2.customer_id
)
Where exists(select * from tab2 t3 where t1.customer_id = t3.customer_id);
commit;
if you only want to update the rows that has a matching row in tab2.
This helps,
Set
-----Original Message-----
From: firebird-support@yahoogroups.com [mailto:firebird-support@yahoogroups.com] On Behalf Of crizoo4712
Sent: 16. januar 2008 11:00
To: firebird-support@yahoogroups.com
Subject: [firebird-support] synchronized update doesn't work properly
Hi All,
the synchronized update, which I was used to using in Oracle, does
not work properly on a FB 1.5 Server!
I have two tables:
tab1:
customer_id integer,
name varchar(100),
email varchar(50))
tab2:
customer_id integer
email varchar(50))
They contain the following values:
tab1:
10000 'McDonald' 'DEFAULT@...'
10001 'OReilly' 'DEFAULT@...'
10002 'McPherson' 'DEFAULT@...'
tab2:
10000 'INFO@...'
As soon as I want to update a certain number of rows in tab1 with a
certain value from tab2 with the following synchronized update, the
field 'email' from the rows of tab1, which doesn't match with the
rows of tab2 via customer_id, is NULLIFIED:
tab1:
10000 'McDonald' 'INFO@...'
10001 'OReilly' <null>
10002 'McPherson' <null>
This is the update-statement:
update tab1 t1
set email =
(
select t2.email from tab2 t2 where t1.customer_id = t2.customer_id
);
commit;
What is my mistake?
Regards, Christoph
update tab1 t1
set email =
(
select t2.email from tab2 t2 where t1.customer_id = t2.customer_id
)
Where exists(select * from tab2 t3 where t1.customer_id = t3.customer_id);
commit;
if you only want to update the rows that has a matching row in tab2.
This helps,
Set
-----Original Message-----
From: firebird-support@yahoogroups.com [mailto:firebird-support@yahoogroups.com] On Behalf Of crizoo4712
Sent: 16. januar 2008 11:00
To: firebird-support@yahoogroups.com
Subject: [firebird-support] synchronized update doesn't work properly
Hi All,
the synchronized update, which I was used to using in Oracle, does
not work properly on a FB 1.5 Server!
I have two tables:
tab1:
customer_id integer,
name varchar(100),
email varchar(50))
tab2:
customer_id integer
email varchar(50))
They contain the following values:
tab1:
10000 'McDonald' 'DEFAULT@...'
10001 'OReilly' 'DEFAULT@...'
10002 'McPherson' 'DEFAULT@...'
tab2:
10000 'INFO@...'
As soon as I want to update a certain number of rows in tab1 with a
certain value from tab2 with the following synchronized update, the
field 'email' from the rows of tab1, which doesn't match with the
rows of tab2 via customer_id, is NULLIFIED:
tab1:
10000 'McDonald' 'INFO@...'
10001 'OReilly' <null>
10002 'McPherson' <null>
This is the update-statement:
update tab1 t1
set email =
(
select t2.email from tab2 t2 where t1.customer_id = t2.customer_id
);
commit;
What is my mistake?
Regards, Christoph