TZQuery is read-only when using stored procedure in SQL

In this forum we will discuss things relating the ZEOSLib 6.6.x stable versions

Moderators: gto, EgonHugeist

Post Reply
maakk
Fresh Boarder
Fresh Boarder
Posts: 3
Joined: 25.10.2008, 13:30

TZQuery is read-only when using stored procedure in SQL

Post by maakk »

First, I'm new to Delphi and Zeoslib, so pardon me if this is a stupid question, but:

- I have TZConnection, TZQuery and TZUpdateSQL
- TZQuery is data source for standard Delphi data controls (TDBEdit, TDBGrid) through a TDataSource

Now, when I set the SQL of TZQuery like this: 'SELECT * FROM PATIENT' (PATIENT is the name of a table in database), I can edit the values of current record in data controls.

But when my SQL is 'SELECT * FROM PL_PATIENT' ('PL_PATIENT' is the name of a stored procedure) all data controls become "readonly".

I'm not talking about making actual updates to database, only about being or not being able to edit the values in DB-aware controls. It works OK, even with complex sql queries, but it stops wroking when I use any name of a stored procedure.

Is this a bug?

Thanks!
seawolf
Zeos Dev Team *
Zeos Dev Team *
Posts: 385
Joined: 04.06.2008, 19:50
Contact:

Post by seawolf »

I think it is not a bug, because Zeos has no possibilty to know (at the moment) what that procedure do and which are the tables interested.

So you can watch a result, but you cannot be modify beacuse of lack of information about tables, columns and relations
maakk
Fresh Boarder
Fresh Boarder
Posts: 3
Joined: 25.10.2008, 13:30

Post by maakk »

I see but what if I need more control over how my data get updated? I thought that TZUpdateSQL is there just to meet such requirement.

I mean, I want to select the data one way, and then insert/update completely other way (namely: using a stored procedure, which e.g. returns the value of the primary key, after I insert new record). So I don't want Zeoslib to guess anything, I want to create the sql parameters myself, and then assing field values to these parameters before insert/update, and then, after commiting the changes, I want to assign the values of output parameters back to the fields of TZQuery.

Is this possible? If so, can anybody please teach me how... :?
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Not sure if that complex situation is possible. But I was thinking it would/should be possible to update the fields when you're using TZUpdateSQL.

Have you tried setting the Fields Readonly property to false after opening the query?

To get back the primary key of the inserted row you could use the RefreshSql property of TZUpdateSql.

Mark
Image
pawelp
Fresh Boarder
Fresh Boarder
Posts: 16
Joined: 18.08.2008, 18:10
Location: Poland

Post by pawelp »

I have a similar Problem, but my sql Query is a Join one and looks something like this:

SELECT
"car"."idnt" AS "Indicator",
"car"."cnumer" AS "customer_numer",
(...)
"customer"."numer" AS "customernnumer",
"customer"."tel" AS "Phone",
(...)
"carmodelinfo"."id" AS "carmodelinfo_Id",
"carmodelinfo"."manufacturer" AS "Car Manufacturer",
(...)
FROM
(("car"
LEFT OUTER JOIN
"customer"
ON
"car"."cnumer" = "customer"."numer")

LEFT OUTER JOIN
"carmodelinfo"
ON
"car"."carmodelinfostamm_id" = "carmodelinfo"."id")


I'm using a ClientDataSet, and I wanted to manipulate the update action in the ClientDataSet.DataSetProbider.BeforeUpdateRecord event. This works just fine for non Join Queries, but when I use a Join, my fields are marked as Read-Only. And changing the property manually doesn't work.

Any Ideas how to mark the fields as non read-only?

I also tryed to use the ZUpdateSQL but the fields are still marked as read only...
Post Reply