Print Thread
View containing 'rowid' does not work
#500 05/09/00 05:54 PM
Joined: May 2000
Posts: 3
Risskov, Denmark
L
lectoc Offline OP
Member
OP Offline
Member
L
Joined: May 2000
Posts: 3
Risskov, Denmark
Having an Oracle view containing 'rowid' does not work when using TOracleDataset. The field simply does not appear in the dataset. However using a TOracleQuery, it works fine. Now, I can not just switch over using TOracleQuery.

Is this an error in DOA, or is there some setting somewhere, that I missed?

An example of a view containing this problem:

CREATE VIEW doa_view
(
ID
)
AS
SELECT rowid FROM sometable.....

What we had to do in this topical situation was to implement the following "hack" in the view:

CREATE VIEW doa_view
(
ID
)
AS
SELECT concat('1', rowid) FROM
sometable.....

This forces the dataset component to believe it is a string field. This works in our current situation.

Regards
Torben.


------------------
Torben M. Christensen


Torben M. Christensen
Re: View containing 'rowid' does not work
#501 05/09/00 10:59 PM
Joined: Sep 1999
Posts: 17
Fresno, CA, USA
M
Member
Offline
Member
M
Joined: Sep 1999
Posts: 17
Fresno, CA, USA
Torben,

The TOracleDataset component uses the ROWID internally to update the table when you post updates to a record. It hides the value from you (making the assumption, I suppose, that the only reason you included a ROWID element in your query was because the DOA docs said to <sigh> ). You can access the ROWID value for the current record using the ROWID property for the dataset.

i.e.

myDataset := TOracleDataset.Create(Self);
myDataset.Session := mySession;
myDataset.SQL.Append('SELECT t.*, t.ROWID from myTable t');
myDataset.Open;
while not myDataset.eof do
begin
// vvvvvvvvvvvvvvv
Memo1.Lines.Append(myDataset.ROWID);
// ^^^^^^^^^^^^^^^
myDataset.next;
end;
myDataset.close;
FreeAndNil(myDataset);

It's a pain, but it works. This even works if the only element in your dataset is the ROWID. It looks like you don't have any fields in your dataset, but you do get records and the navigational commands (next, first, etc.) seem to work ok.

Hope it helps...Michael


Michael Bonner
Programmer/Analyst III
City of Fresno
E-Mail: michael.bonner@ci.fresno.ca.us
Visit our web site at www.ci.fresno.ca.us
Re: View containing 'rowid' does not work
#502 05/11/00 05:11 PM
Joined: Aug 1999
Posts: 22,216
Member
Offline
Member
Joined: Aug 1999
Posts: 22,216
The easiest way to include the rowid as a field, is to convert it to a varchar2 field by using the rowidtochar function:

CREATE VIEW doa_view AS SELECT rowidtochar(rowid) id FROM sometable.....

------------------
Marco Kalter
Allround Automations


Marco Kalter
Allround Automations
Re: View containing 'rowid' does not work
#503 05/11/00 05:12 PM
Joined: May 2000
Posts: 3
Risskov, Denmark
L
lectoc Offline OP
Member
OP Offline
Member
L
Joined: May 2000
Posts: 3
Risskov, Denmark
Hi Michael.

Thanks for your reply. Unfortunately I can not use this.

The reason we have a problem is that we are using a framework that demands a unique ID field on any table (or views). On this particular table we do not have a unique field called ID. Therefore we are using a view containing a field called ID. This field must be unique. Therefore we used rowid.

In other words - the field we must read from the dataset is named "ID", and it must be contained in the Fields of the dataset. We can not access some other property of the dataset (this would mean that we had to change our framework).

Regards
Torben.


Torben M. Christensen
Re: View containing 'rowid' does not work
#504 05/11/00 05:15 PM
Joined: May 2000
Posts: 3
Risskov, Denmark
L
lectoc Offline OP
Member
OP Offline
Member
L
Joined: May 2000
Posts: 3
Risskov, Denmark
Hi Marco.

Thanks for your reply. You posted your reply just while I was replying Michael.

Seems that we can use your suggestion without any problems.

However I still find it strange that such a field from a view is not included in a TOracleDataset, but anyways - it works!

Thanks!

Regards
Torben.


Torben M. Christensen

Moderated by  support 

Link Copied to Clipboard
Powered by UBB.threads™ PHP Forum Software 7.7.4
(Release build 20200307)
Responsive Width:

PHP: 7.1.33 Page Time: 0.040s Queries: 13 (0.016s) Memory: 2.5156 MB (Peak: 3.0394 MB) Data Comp: Off Server Time: 2024-05-12 05:26:43 UTC
Valid HTML 5 and Valid CSS