Subject | Re: How to detect a record changed between read and update? |
---|---|
Author | constantijnw |
Post date | 2004-06-17T16:35:08Z |
Hi Martijn,
--- In firebird-support@yahoogroups.com, "Martijn Tonies"
<m.tonies@u...> wrote:
an api but how can I get it inside a sp?
--- In firebird-support@yahoogroups.com, "Martijn Tonies"
<m.tonies@u...> wrote:
> Hi,Still used in TDataSetProvider. Ok, RowsAffected can be retrieved with
>
> > > There are many different ways.
> >
> > The best will do, thank you.
> >
> > > The easiest is to use snapshot transaction (which is default).
> > > Since snapshot provides consistent view of whole database,
> > > it can't see changes that happened after its start,
> > > thus in this transaction you can't update such records.
> > >
> > > Ivan
> >
> > You mean I shouldn't do this? You can't start a transaction in a sp,
> > right?
>
> No, you can't. But the SP will run in the transaction context
> that executed it.
>
> Another way of checking for changes is as such:
>
> UPDATE mytable
> SET mycolumn = newvalue
> WHERE mycolumn = oldvalue
> AND pkcolumn = pkvalue
>
> Now, if someone else changed "mycolumn", then this UPDATE
> will return a "rows affected" of 0 -> hence, someone else changed
> it.
>
> In old "bde" speak, this was an "update-where-all" with the
> TUpdateSQL component.
an api but how can I get it inside a sp?
>MS SQL
> With regards,
>
> Martijn Tonies
> Database Workbench - developer tool for InterBase, Firebird, MySQL &
> Server.
> Upscene Productions
> http://www.upscene.com