I use Odac 6.90
If I use a select with no order prior to version 10 of oracle and I do a refresh after a change (as in code below) points to the same record that I had pointed earlier. If I do the same with oracle 10 it points on a different record. I noticed that after every update on the table by the refresh does not ever get a result set ordered in the same way. I do not want to put order not to sacrifice performance. Can you tell me if there is a property or method to prevent that happening, and get the same effect on older versions of oracle?
begin
try
Index := DataSet.GetBookmark;
TOraDataSet(DataSet).Refresh;
if (not DataSet.IsEmpty) then TOraDataSet(DataSet).GotoBookmark(Index);
finally
DataSet.FreeBookmark(Index);
end;
end;
Thanks a lot
problem to bookmark record after update in oracle 10
-
fabriziodc
- Posts: 4
- Joined: Wed 09 Feb 2005 10:31
-
fabriziodc
- Posts: 4
- Joined: Wed 09 Feb 2005 10:31
I do not want to use the "locate" it will penalize the performance, So why the gotobookmark worked perfectly until the oracle 9?
In fact, running the command "alter session set optimizer_mode = 'rule'" on my "oracle 10" and now is working. But I can not use this command because already the version 11 will be deprecated. So the problem can not be gotobookmark but something has changed from 10 and earlier versions of oracle and the ODAC on the refresh, because at every refresh, after update, the result set changes.
In fact, running the command "alter session set optimizer_mode = 'rule'" on my "oracle 10" and now is working. But I can not use this command because already the version 11 will be deprecated. So the problem can not be gotobookmark but something has changed from 10 and earlier versions of oracle and the ODAC on the refresh, because at every refresh, after update, the result set changes.
Hello,
If you are using a bookmark, and after setting it you have deleted a record before it, the bookmark will be broken (it will point to another record) in all Oracle versions.In this case the bookmark will point to the next record (f you have deleted one record) or it will point to the bookmark+N record (bookmark+the number of records deleted before bookmark). If you delete a record after the bookmark, the bookmark will be correct.
Please execute the following example on Oracle 9:
and the bookmark will point to the record with id = 3 instead of the one with id = 2
If you are using a bookmark, and after setting it you have deleted a record before it, the bookmark will be broken (it will point to another record) in all Oracle versions.In this case the bookmark will point to the next record (f you have deleted one record) or it will point to the bookmark+N record (bookmark+the number of records deleted before bookmark). If you delete a record after the bookmark, the bookmark will be correct.
Please execute the following example on Oracle 9:
Code: Select all
CREATE TABLE TEST_TABLE(
ID NUMBER,
TEXT VARCHAR2(50)
);
INSERT INTO TEST_TABLE VALUES(1,'text1');
INSERT INTO TEST_TABLE VALUES(2,'text2');
INSERT INTO TEST_TABLE VALUES(3,'text3');
var
Index: Pointer;
OraQuery: TOraQuery;
OraSession: TOraSession;
begin
OraSession:= TOraSession.Create(nil);
OraSession.Server:= '...';
OraSession.Username:= '...';
OraSession.Password:= '...';
OraSession.Connect;
OraQuery:= TOraQuery.Create(nil);
OraQuery.Session:= OraSession;
OraQuery.SQL.Text:= 'SELECT * FROM TEST_TABLE';
OraQuery.Open;
OraQuery.Next; //goto ID= 2
ShowMessage(OraQuery.FieldByName('TEXT').AsString); //show current record
Index := OraQuery.GetBookmark; // set bookmark to id = 2
OraSession.ExecSQL('DELETE FROM ALEXP WHERE ID=1', []); // delete first record
OraQuery.Refresh;
if (not OraQuery.IsEmpty) then
begin
OraQuery.GotoBookmark(Index);
ShowMessage(OraQuery.FieldByName('TEXT').AsString);//show current record
end;
OraQuery.FreeBookmark(Index);
-
fabriziodc
- Posts: 4
- Joined: Wed 09 Feb 2005 10:31
AlexP,
thank you for your reply. The situation in the example you posted is clear; the problem is that the same also happens after an UPDATE, non only after a delete... Moreover, the ALTER SESSION command I posted before changes the behavior of the refresh + GotoBookmark commands, as it works just fine (as in Oracle 8 and 9).
As I said before, I would prefer to avoid using the Locate method after an update due to performance reasons.
Thank you in advance for any help.
thank you for your reply. The situation in the example you posted is clear; the problem is that the same also happens after an UPDATE, non only after a delete... Moreover, the ALTER SESSION command I posted before changes the behavior of the refresh + GotoBookmark commands, as it works just fine (as in Oracle 8 and 9).
As I said before, I would prefer to avoid using the Locate method after an update due to performance reasons.
Thank you in advance for any help.