Locks

Ruslan Zasukhin ruslan_zasukhin at valentina-db.com
Mon Nov 2 10:29:32 CST 2009


On 11/1/09 8:19 PM, "Thomas Flemming" <tf at ttqv.com> wrote:

Hi Thomas,

> I'm just wondering if this is correct:
> 
> I have multiple forms displaying data of the same table.
> For this I use several cursors like this, which are open the whole until the
> program ends:
> 
> mCur = mDB.SqlSelect(mSQL, kClientSide, kNoLocks, kRandom)
> 
> This works.
> 
> 
> To edit some values in the table I temporarily create a new cursor:
> 
> cur = mDB.SqlSelect("select * from [mytable], _
>                      kServerSide, kReadWrite, kForwardOnly)
> cur.Position = position_to_edit
> cur.Field(1).Value = newvalue1
> cur.Field(2).Value = newvalue2
> cur.UpdateRecord()
> cur.Dispose()
> 
> It also works, but is it the right way?

A) Better select in the second cursor only ONE record, which you want to
edit

    SELECT ... FROM T ... WHERE RecID = XXX

B) it is possible also to use just UPDATE command

    UPDATE ...  fld1 = value1  ... WHERE RecID = XXX


C) And it is possible to use both these ways with SQL binding

    "UPDATE T SET fld1 = :1, WHERE RECID = :5"

See example SQL Binding and read wiki about why this can be better.


-- 
Best regards,

Ruslan Zasukhin
VP Engineering and New Technology
Paradigma Software, Inc

Valentina - Joining Worlds of Information
http://www.paradigmasoft.com

[I feel the need: the need for speed]




More information about the Valentina mailing list