Subject | Re: [IBO] "for updating" clause in Ver 4.7 Beta15 |
---|---|
Author | Helen Borrie |
Post date | 2007-01-26T00:18:15Z |
At 08:25 AM 26/01/2007, you wrote:
is a valid argument in a SELECT clause. But its purpose is not what
you seem to think. It doesn't make a DSQL select "updatable". This
is some myth that was spread around this list years ago.
The SELECT.....FOR UPDATE belongs in a cursor structure inside a PSQL
module or in host applications that are written in ESQL (embedded
SQL, a.k.a static SQL). IBO is not an ESQL interface: it surfaces
only DSQL to applications. (Internally, IBO uses this mechanism at
the API level in its management of TIB_Cursor - it is added by IBO
when needed it so you shouldn't add it yourself).
Just leave it out. It doesn't belong in any DSQL queries in your IBO
application.
The "updatable dataset" notion in Delphi components, including IBO,
is a hack. There is really no such thing as an updatable
dataset. The components make them seem so by internally constructing
the relevant DML statements with a parameterised WHERE clause that
refers to the output fields of the dataset. In IBO you can "roll
your own" using the XxxxSQL properties (InsertSQL, EditSQL,
DeleteSQL) of the dataset components. For a single-table dataset
with correct KeyLinks, IBO constructs and loads these statements
automatically if RequestLive is true.
(Delphi's TUpdateSQL provides a similar option for TDataset
derivatives but in IBO, the TDataset-compatible components surface
the XxxxxSQL properties and make TUpdateSQL redundant.)
To get an updatable set from a single-table query in IBO, set your
KeyLinks and either flag RequestLive true or provide custom XxxxxSQL
statements .
Note that, from Firebird 1.5 onward, the FOR UPDATE keyword has been
borrowed into DSQL as part of the implementation of server-side
pessimistic locking, in combination with the WITH LOCK clause. I
won't go into details - they are complicated and irrelevant here -
you can read about it in the Fb 1.5 release notes. It is definitely
NOT to be used with arbitrary multi-row selects!
Helen
>Hi, when I started using the Ver 4.7 betas my Delphi app bombed onThere is no such token as "for updating". There is FOR UPDATE which
>every TIBOQuery object that contained "for updating" in the SQL code.
> I removed all instances and all works well, so I didn't think too
>much about it, figuring maybe Jason wanted to encourage explicit use
>of the RequestLive property.
>
>But now I find that this clause no longer works ("Token unknown") in
>the IB_SQL utility either (IB_SQL_IBO_4_7_Beta15) and I don't seem
>able to use it for quick & dirty table edits anymore. Am I missing
>something? How do I make simple select queries editable in IB_SQL?
is a valid argument in a SELECT clause. But its purpose is not what
you seem to think. It doesn't make a DSQL select "updatable". This
is some myth that was spread around this list years ago.
The SELECT.....FOR UPDATE belongs in a cursor structure inside a PSQL
module or in host applications that are written in ESQL (embedded
SQL, a.k.a static SQL). IBO is not an ESQL interface: it surfaces
only DSQL to applications. (Internally, IBO uses this mechanism at
the API level in its management of TIB_Cursor - it is added by IBO
when needed it so you shouldn't add it yourself).
Just leave it out. It doesn't belong in any DSQL queries in your IBO
application.
The "updatable dataset" notion in Delphi components, including IBO,
is a hack. There is really no such thing as an updatable
dataset. The components make them seem so by internally constructing
the relevant DML statements with a parameterised WHERE clause that
refers to the output fields of the dataset. In IBO you can "roll
your own" using the XxxxSQL properties (InsertSQL, EditSQL,
DeleteSQL) of the dataset components. For a single-table dataset
with correct KeyLinks, IBO constructs and loads these statements
automatically if RequestLive is true.
(Delphi's TUpdateSQL provides a similar option for TDataset
derivatives but in IBO, the TDataset-compatible components surface
the XxxxxSQL properties and make TUpdateSQL redundant.)
To get an updatable set from a single-table query in IBO, set your
KeyLinks and either flag RequestLive true or provide custom XxxxxSQL
statements .
Note that, from Firebird 1.5 onward, the FOR UPDATE keyword has been
borrowed into DSQL as part of the implementation of server-side
pessimistic locking, in combination with the WITH LOCK clause. I
won't go into details - they are complicated and irrelevant here -
you can read about it in the Fb 1.5 release notes. It is definitely
NOT to be used with arbitrary multi-row selects!
Helen