Subject Re: [firebird-support] Re: How to detect a record changed between read and update?
Author Walter Neumann
Am Donnerstag, 17. Juni 2004 18:35 schrieb constantijnw:
> Hi Martijn,
>
> --- In firebird-support@yahoogroups.com, "Martijn Tonies"
>
> <m.tonies@u...> wrote:
> > Hi,
> >
> > > > 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.
>
> Still used in TDataSetProvider. Ok, RowsAffected can be retrieved with
> an api but how can I get it inside a sp?

Row_Count returns the number of rows, affected by the last DML statement in a
SP.
>
> > With regards,
> >
> > Martijn Tonies
> > Database Workbench - developer tool for InterBase, Firebird, MySQL &
>
> MS SQL
>
> > Server.
> > Upscene Productions
> > http://www.upscene.com
>
>
>
> Yahoo! Groups Links
>
>
>