Hi,
This query returns one row and one field of type cursor.
Can ODAC read the data from that field?
select cursor(select 1,2,'Test' X from dual) TestCursorField from dual
Does ODAC support cursor field type?
Re: Does ODAC support cursor field type?
Hello
Yes, you can. Here is an example:
Yes, you can. Here is an example:
Code: Select all
begin
OraQuery1.SQL.Text := 'select cursor(select 1,2,''Test'' X from dual) TestCursorField from dual';
OraQuery1.Open;
OraQuery2.Cursor := TCursorField(OraQuery1.Fields[0]).AsCursor;
OraQuery2.Open;
end;Re: Does ODAC support cursor field type?
Well, that was simple. Thanks 
Re: Does ODAC support cursor field type?
If I open the cursor for the first time it will work. But when I try to open the cursor for the second time it will generate access violation. Is there a proper way to close it before the second open or some other refetch trick that will allow the second opening?
*EDIT* Calling OraQuery1.Refresh; will work for the second opening. I find this way rather brutal. Is there another more lightweight method to do this?
*EDIT* Calling OraQuery1.Refresh; will work for the second opening. I find this way rather brutal. Is there another more lightweight method to do this?
Code: Select all
begin
OraQuery1.SQL.Text := 'select cursor(select 1,2,''Test'' X from dual) TestCursorField from dual';
OraQuery1.Open;
OraQuery2.Cursor := TCursorField(OraQuery1.Fields[0]).AsCursor;
// Here the cursor is fetched
OraQuery2.Open;
//Does not matter if I close this
OraQuery2.Close;
// If I open the cursor for the second time I will get access violation
OraQuery3.Cursor := TCursorField(OraQuery1.Fields[0]).AsCursor;
OraQuery3.Open;
end;Re: Does ODAC support cursor field type?
Hello,
We cannot reproduce the error when re-opening the cursor on the latest ODAC version, please specify your ODAC version.
In addition, if you are trying to re-open the cursor not having closed it, you won't retrieve data in this case, as the cursor is already open and data is retrieved. Therefore, for retrieving data from the cursor again, you should preliminarily close it.
Closing and opening of DataSet takes place within the Refresh method, therefore calling the Refresh method is similar to calling the Open/Close methods, the only difference is that, when calling the Refresh method after opening DataSet, there occurs the positioning to the record, where the cursor was.
We cannot reproduce the error when re-opening the cursor on the latest ODAC version, please specify your ODAC version.
In addition, if you are trying to re-open the cursor not having closed it, you won't retrieve data in this case, as the cursor is already open and data is retrieved. Therefore, for retrieving data from the cursor again, you should preliminarily close it.
Closing and opening of DataSet takes place within the Refresh method, therefore calling the Refresh method is similar to calling the Open/Close methods, the only difference is that, when calling the Refresh method after opening DataSet, there occurs the positioning to the record, where the cursor was.