Subject | RE: [firebird-support] read the next record of the table |
---|---|
Author | Mercea Paul |
Post date | 2008-06-13T12:37:03Z |
Hi Fidel
At first look you can thing that every time you update the entire table, but
for each row you execute a select !
Regards,
Paul
From: firebird-support@yahoogroups.com
[mailto:firebird-support@yahoogroups.com] On Behalf Of Fidel Viegas
Sent: 13 June 2008 14:10
To: firebird-support@yahoogroups.com
Subject: Re: [firebird-support] read the next record of the table
On Fri, Jun 13, 2008 at 12:03 PM, Svein Erling Tysvær
<svein.erling.tysvaer@...
<mailto:svein.erling.tysvaer%40kreftregisteret.no> > wrote:
From what I can see in the statement, that will update every single
row, because there is no filter condition in the update statement
itself.
if you do "update table set col = xxx", this will change every single
row in the table. The subselect is correct, but that is a condition
missing in the udpate statement, which I haven't figured out what it
is. Here is how it should be:
UPDATE myTable m
SET m.field_b =
(
SELECT m2.field_a
from myTable m2
where m2.row_id = m.row_id + 1
) where <condition>;
I haven't really figured what the <condition> is, but would like to
know if someone comes up with the solution to this.
Fidel.
[Non-text portions of this message have been removed]
At first look you can thing that every time you update the entire table, but
for each row you execute a select !
Regards,
Paul
From: firebird-support@yahoogroups.com
[mailto:firebird-support@yahoogroups.com] On Behalf Of Fidel Viegas
Sent: 13 June 2008 14:10
To: firebird-support@yahoogroups.com
Subject: Re: [firebird-support] read the next record of the table
On Fri, Jun 13, 2008 at 12:03 PM, Svein Erling Tysvær
<svein.erling.tysvaer@...
<mailto:svein.erling.tysvaer%40kreftregisteret.no> > wrote:
> What you do should work. The one thing I would expect to cause this tofail,
> is if you didn't commit the transaction. Another things that could be ofdate
> influence, is the field type of row_id, if it is an integer, decimal or
> (provided dialect 3) field, I cannot see how this could fail. Floatingpoint
> numbers is something completely different, they're approximate (may beHi Set,
> 1.00000000232 when you think it is just 1) and shouldn't be used with
> comparison for equality. Of course, if field_a and field_b is incompatible
> field types, then you would also get trouble, but that would normally be
> very visible for you when you try to prepare the statement.
From what I can see in the statement, that will update every single
row, because there is no filter condition in the update statement
itself.
if you do "update table set col = xxx", this will change every single
row in the table. The subselect is correct, but that is a condition
missing in the udpate statement, which I haven't figured out what it
is. Here is how it should be:
UPDATE myTable m
SET m.field_b =
(
SELECT m2.field_a
from myTable m2
where m2.row_id = m.row_id + 1
) where <condition>;
I haven't really figured what the <condition> is, but would like to
know if someone comes up with the solution to this.
Fidel.
[Non-text portions of this message have been removed]