Board index » delphi » TQuery write permission

TQuery write permission

Hi ,

Does TQuery  dataset control has any simillar property for ReadOnly as
TTable dataset control  has ?
Query.Edit -  does not work .

Many Thanks ,

Eyal.

 

Re:TQuery write permission


Hi Eyal,
tQuery does not have "ReadOnly" property.
Some queries, however, return result set that
cannot be modified directly. Check the "CanModify"
property. For example, if you have two or more tables
joined in the query, CanModify is false.
You can get around this by using cached updates
and UpdateObject (tUpdateSQL) together with the query.
--
Roman
(please remove STOPSPAM. in header)
URL:  www.rksolution.cz (Delphi corner)
MAIL: I...@rksolution.cz
Quote
Eyal wrote in message <01bdf10c$c26f0840$LocalHost@m-e-a>...
>Hi ,

>Does TQuery  dataset control has any simillar property for ReadOnly as
>TTable dataset control  has ?
>Query.Edit -  does not work .

>Many Thanks ,

>Eyal.

Re:TQuery write permission


You can use the "RequestLive" property and under the right circimstances
this means that you can modify the result.

Per-Eric Jenshagen

Quote
Roman Krejci wrote:
> Hi Eyal,
> tQuery does not have "ReadOnly" property.
> Some queries, however, return result set that
> cannot be modified directly. Check the "CanModify"
> property. For example, if you have two or more tables
> joined in the query, CanModify is false.
> You can get around this by using cached updates
> and UpdateObject (tUpdateSQL) together with the query.
> --
> Roman
> (please remove STOPSPAM. in header)
> URL:  www.rksolution.cz (Delphi corner)
> MAIL: I...@rksolution.cz

> Eyal wrote in message <01bdf10c$c26f0840$LocalHost@m-e-a>...
> >Hi ,

> >Does TQuery  dataset control has any simillar property for ReadOnly as
> >TTable dataset control  has ?
> >Query.Edit -  does not work .

> >Many Thanks ,

> >Eyal.

Re:TQuery write permission


You cannot edit a query result set unless you set the RequestLive property
to True and your query meets the requirements in the on-line help.

--
Bill Todd
(Sorry but TeamB cannot answer questions received via email)
(Remove nospam from my email address to contact me for any other reason)

Re:TQuery write permission


You must make sure that there is an index for the table already
existing when using an Order By clause. The help file on live result
set criteria is specific on this. If you don't have an index created
for the field Custname, then the result set will be read-only.

Woody

Quote
Kerry Neighbour wrote in message <361BD9EA.E9606...@simcomcity.com>...

>"Bill Todd (TeamB)" wrote:

>> You cannot edit a query result set unless you set the RequestLive
property
>> to True and your query meets the requirements in the on-line help.

>I am having this same problem. And I cannot find anywhere in the Help
>where it specifies what these requirements are. I can see where it
>mentions them, but not what they actually are. If you could give some
>pointers to where they are listed?

>For example - this query is ReadOnly

>"Select * from customers.dbf ORDER BY Custname"

>This query is not.

>"Select * from customers.dbf"

>So it seems to me that ANY query with an ORDER BY statement is
ReadOnly.
>Surely this is not correct?

Re:TQuery write permission


On Thu, 08 Oct 1998 07:15:22 +1000, Kerry Neighbour

Quote
<kneighb...@simcomcity.com> wrote:
>> You cannot edit a query result set unless you set the RequestLive property
>> to True and your query meets the requirements in the on-line help.

>I am having this same problem. And I cannot find anywhere in the Help
>where it specifies what these requirements are. I can see where it
>mentions them, but not what they actually are. If you could give some
>pointers to where they are listed?

To be more specific, you cannot find this documented in the *Delphi* online
help. That is because Delphi has no SQL of its own. Rather, you are subject
to the capabilities amd limitations of the database back-end used. In your
case, using a dBASE table, local SQL rules apply. Local SQL rules for live
queries are documented in the local SQL online help file, LOCALSQL.HLP,
found in the main BDE directory. Had you been using some other database
type, you would need to consult its documentation.

Quote
>For example - this query is ReadOnly

>"Select * from customers.dbf ORDER BY Custname"

>This query is not.

>"Select * from customers.dbf"

>So it seems to me that ANY query with an ORDER BY statement is ReadOnly.
>Surely this is not correct?

Surely you are right: this is not correct. By default the result set
produced by a SELECT statement with an ORDER BY clause will be read-only.
Under specific circumstances, this read-only effect can be negated. (This,
too, is described in the local SQL help file.)

For dBASE tables, a simple index (one based on only one field) can negate
the read-only effect of an ORDER BY clause if: 1) the ORDER BY is based on
only one field and 2) it is based on the one field that the index uses.

Without having an index to accommodate this, the result set is written to a
temporary table and temporary tables are read-only. You can get around
that, too. Either use a TClientDataSet component to get the data
(Client/Server edition only) or use the combination of cached updates and
an update object.

//////////////////////////////////////////////////////////////////////////
Steve Koterski                 "What is success in this world? I would say
Technical Publications         it consists of four simple things: to live
INPRISE Corporation            a lot, to love a lot, to laugh a lot, and
http://www.inprise.com/delphi  from it all, to learn a lot."
                                                     -- Richard J. Needham

Re:TQuery write permission


Surely this _is_ correct for local Paradox and dBase tables<g>. See the
topic Updatable Queries in the D4 Local SQL help file.

--
Bill Todd
(Sorry but TeamB cannot answer questions received via email)
(Remove nospam from my email address to contact me for any other reason)

Re:TQuery write permission


Quote
"Bill Todd (TeamB)" wrote:

> You cannot edit a query result set unless you set the RequestLive property
> to True and your query meets the requirements in the on-line help.

I am having this same problem. And I cannot find anywhere in the Help
where it specifies what these requirements are. I can see where it
mentions them, but not what they actually are. If you could give some
pointers to where they are listed?

For example - this query is ReadOnly

"Select * from customers.dbf ORDER BY Custname"

This query is not.

"Select * from customers.dbf"

So it seems to me that ANY query with an ORDER BY statement is ReadOnly.
Surely this is not correct?

Re:TQuery write permission


Quote
> >For example - this query is ReadOnly

> >"Select * from customers.dbf ORDER BY Custname"

> >This query is not.

> >"Select * from customers.dbf"

> >So it seems to me that ANY query with an ORDER BY statement is ReadOnly.
> >Surely this is not correct?

> Surely you are right: this is not correct. By default the result set
> produced by a SELECT statement with an ORDER BY clause will be read-only.
> Under specific circumstances, this read-only effect can be negated. (This,
> too, is described in the local SQL help file.)

> For dBASE tables, a simple index (one based on only one field) can negate
> the read-only effect of an ORDER BY clause if: 1) the ORDER BY is based on
> only one field and 2) it is based on the one field that the index uses.

Ah - this is very interesting. I would argue that a SELECT/ORDER BY
query should be readonly. I see no reason why it should be (unlike
Joins, etc). But anyway, m{*word*203}issues aside, you are obviously correct.

I use compound indexes (ie CDX files). This would seem to be the
problem?  If I used discreet MDX files (ie one for each index field),
would this fix the readonly problem?

All of my indexes are simple one field ones - a very few are expression
indexes (ie UPPER(fieldname)). Are these allowed?

Anyway - thanks for the pointers to the Help file...will have a look. I
have to say that Readonly queries kind of makes queries somewhat useless
in Delphi, except for printouts. I am used to Access, where I use
queries for practically everything.

Other Threads