DBGrid not updateable

Equinox

Member²
Hello there,

First of all, I'm using DOA components 4.0.7.1 in combination with delphi 7.

In my application I have a TDBGrid into which I want to load the resulting ref cursor data from a call to a stored procedure in an oracle database.

This all works well, I call the procedure using a TOracleQuery with a complex variable of type otCursor assigned to another TOracleQuery instance as it is described in the help files.

Now I assign this cursor TOracleQuery instance to a TOracleDataset's ExternalCursor property and assign this Dataset to my grid.

Now the problem comes up if I try to edit values in the grid, because nothing happens. The grid & dataset are set to readonly := false and the edit mode in the grid is enabled. I suppose I need to give some update sql code to the dataset in order to make it work, but I don't know how.

On some other source, I found out that I have to add selection of the rowID, which I did in the stored procedure which returns the ref cursor. Now after this change, when I try to edit values in the grid, the application crashes with an EOracleError "Table 1 does not exist". So I found I have to set the UpdatingTable property of the Dataset which I did. On the next try to edit a value, I got EOracleError "Field 1 does not exist".

Now I'm pretty much stuck at this point, as I have no clue what else I need to do.

Is my approach all wrong or am I just missing anything ? Is there any link to an example to make this work ?

Thanks...

Here the interesting part of the code :

Code:
mDSDCIDs := TOracleDataset.Create(self);
mDSDCIDs.ExternalCursor := CursorQuery;
mDSDCIDs.UpdatingTable := 'tbl_dcids';
//what else here to avoid "field 1 does not exist" ?
mDSDCIDs.Session := mSession;
mDSDCIDs.Active := true;
mDataSource.DataSet := mDSDCIDs;
mGridDCIDs.Datasource := mDataSource;
 
Last edited:
If you set the UpdatingTable property to tbl_dcids, then the names of the updateable fields from the query must match the column names of the tbl_dcids table. Can you verify this?

I'm not sure where the "Field 1 does not exist" error comes from though.
 
Which query are you refering to if you say the names of the updateable fields from the query ?

I'm not really using any query on delphi side, I only call a stored procedure into a ref cursor TOracleQuery object and add that returned object as ExternalCursor to the dataset.

All I do then is to change the display name of the columns in the Grid but I don't think this should affect the update...

If it doesn't work with the update in general, would there be a way to call a 2nd stored procedure for the update ? I'm thinking of something like adding a 2nd procedure call to the Query's SQL text which calls a procedure for the update process, but I'm not sure if this would work ?
 
The TOracleQuery that you use as external cursor has a SQL statement, which returns a number of fields. These field names should match the updating table.
 
Note: The DeptAPI demo project demonstrates a complete query/update/insert/delete replacement through package calls.
 
The procedure I call returns some fields from the table tbl_dcids in a ref cursor, but not all. I don't see how it would be possible that the field names don't match because it's the same table I'm selecting from and updating to.

Where can I find this demo project ?
 
There is no deptAPI in that folder. I've checked the other demos there like DeptGrid or PkgApply but none of them really helps me with my problem.
 
I've now got a workaround where I intercept KeyDown events on the grid and call a second stored procedure when 'enter' is pressed, but it feels really ugly and the user doesn't see what he types in the grid, because it does not allow edit mode.

I'd really appreciate an example of how this is supposed to work properly.
 
The PkgApply demo is the one I meant. Sorry for the confusion. It takes the result set from a cursor and applies the changes through packaged functions.
 
Never mind, I gave it up and use a string grid now instead, where I do everything manually. Sad, but I can't search for a solution to this for another 2 weeks.

Thanks anyway.
 
Back
Top