Page 1 of 1
TCustomDADataSet.GotoCurrent in version 5.2.7
Posted: Thu 27 Feb 2014 12:37
by ketas
Hi,
in version 5.0.2 this code was o.k.
...
Dataset.open;
Dataset.moveby(10);
DSet := TCustomUniDataSet.Create( nil );
DSet.Assign( Dataset );
Dset.open;
DSet.GotoCurrent( dataset );
In version 5.2.7 are not datasets synchronised, DSet stay on record 1.
Please answer my ticket
http://forums.devart.com/viewtopic.php?f=28&t=29033 .
As with all version after 5.0.2 we have to make downgrade to 5.0.2.
Since we currently dependent on this product, is this situation for us unpleasant.
Best Regards. Vojslav
Re: TCustomDADataSet.GotoCurrent in version 5.2.7
Posted: Mon 03 Mar 2014 14:14
by AlexP
Hello,
We cannot reproduce the problem. The below sample returns correct data. Please modify it so that the problem can be reproduced and send it back to us.
Code: Select all
program Project8;
{$APPTYPE CONSOLE}
uses
SysUtils, PostgreSQLUniProvider, Uni;
var
UniConnection: TUniConnection;
UniQuery: TUniQuery;
DSet: TCustomUniDataSet;
begin
UniConnection := TUniConnection.Create(nil);
try
UniConnection.ConnectString := 'ProviderName=PostgreSQL;Host=..;port=...;database=...;UID=...;PWD=...';
UniConnection.Connect;
UniQuery := TUniQuery.Create(nil);
try
UniQuery.Connection := UniConnection;
UniQuery.SQL.Text := 'Select * from test';
UniQuery.Open;
UniQuery.MoveBy(10);
DSet := TCustomUniDataSet.Create(nil);
try
DSet.Assign(UniQuery);
DSet.Open;
DSet.GotoCurrent(UniQuery);
Assert(DSet.RecNo = UniQuery.RecNo);
finally
DSet.Free;
end;
finally
UniQuery.Free;
end;
finally
UniConnection.Free;
end;
end.
Re: TCustomDADataSet.GotoCurrent in version 5.2.7
Posted: Mon 03 Mar 2014 17:04
by ketas
Hi,
i forgot to say, that database is oracle, example is here:
tform9.dfm
Code: Select all
object Form9: TForm9
Left = 0
Top = 0
Caption = 'Form9'
ClientHeight = 227
ClientWidth = 501
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Button1: TButton
Left = 112
Top = 176
Width = 75
Height = 25
Caption = 'go'
TabOrder = 0
OnClick = Button1Click
end
object UniConnection1: TUniConnection
ProviderName = 'Oracle'
SpecificOptions.Strings = (
'Oracle.UseUnicode=True')
Left = 152
Top = 48
end
object OracleUniProvider1: TOracleUniProvider
Left = 240
Top = 48
end
object UniTransaction1: TUniTransaction
DefaultConnection = UniConnection1
Left = 336
Top = 48
end
object UniScript1: TUniScript
Connection = UniConnection1
Left = 64
Top = 40
end
end
tform9.pas
Code: Select all
unit GotoCurrent;
interface
uses
Winapi.Windows,
Winapi.Messages,
System.SysUtils,
System.Variants,
System.Classes,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs,
Data.DB,
MemDS,
DBAccess,
Uni,
UniProvider,
OracleUniProvider,
JvStringHolder,
Vcl.StdCtrls,
DAScript,
UniScript;
type
TForm9 = class( TForm )
UniConnection1 : TUniConnection;
OracleUniProvider1 : TOracleUniProvider;
UniTransaction1 : TUniTransaction;
Button1 : TButton;
UniScript1 : TUniScript;
procedure Button1Click( Sender : TObject );
private
{ Private declarations }
end;
var
Form9 : TForm9;
implementation
{$R *.dfm}
{ TForm9 }
procedure TForm9.Button1Click( Sender : TObject );
var
DsetOrig : TUniQuery;
DsetDeriv : TUniQuery;
begin
with UniScript1 do begin
sql.Text := 'CREATE TABLE test_table( id NUMBER NOT NULL, name VARCHAR2( 50 CHAR ) NOT NULL );';
execute;
sql.Text := 'ALTER TABLE test_table ADD ( CONSTRAINT test_table_PK PRIMARY KEY( id ) ); ';
execute;
sql.Text := 'INSERT INTO TEST_TABLE ( ID, NAME )VALUES( 1, ''one'' ); ';
execute;
sql.Text := 'INSERT INTO TEST_TABLE ( ID, NAME )VALUES( 2, ''two'' ); ';
execute;
end;
DsetOrig := TUniQuery.Create( self );
DsetDeriv := TUniQuery.Create( self );
try
with DsetOrig do begin
connection := UniConnection1;
sql.Text := 'select id,name from test_table';
Prepare;
Open;
moveBy( 1 );
end;
DsetDeriv.Assign( DsetOrig );
DsetDeriv.GotoCurrent( DsetOrig );
finally
DsetOrig.Close;
DsetOrig.Free;
DsetDeriv.Close;
DsetDeriv.Free;
UniScript1.sql.Text := 'drop table test_table';
UniScript1.execute;
end;
end;
end.
Best regards. Vojslav
Re: TCustomDADataSet.GotoCurrent in version 5.2.7
Posted: Mon 03 Mar 2014 19:49
by ketas
hi,
note to upper post, command assign ends with error id field not found. vojslav
Re: TCustomDADataSet.GotoCurrent in version 5.2.7
Posted: Tue 04 Mar 2014 08:50
by AlexP
The error occurs due to that DataSet is not open and corresponding fields are not created. Replace the code
Code: Select all
DsetDeriv.Assign( DsetOrig );
DsetDeriv.GotoCurrent( DsetOrig );
with
Code: Select all
DsetDeriv.Assign( DsetOrig );
DsetDeriv.Open;
DsetDeriv.GotoCurrent( DsetOrig );
Assert(DsetDeriv.RecNo = DsetOrig.RecNo);
and your sample will work correctly
Re: TCustomDADataSet.GotoCurrent in version 5.2.7
Posted: Tue 04 Mar 2014 14:09
by ketas
Hi,
thanks for correction, in really application I had dataset open,
in one db it is ok in another not, in 5.0.2 was both ok.
I will search further. Best regards. Vojslav
Re: TCustomDADataSet.GotoCurrent in version 5.2.7
Posted: Tue 04 Mar 2014 14:49
by ketas
Hi,
I found problem, we have amount of oracle database which has from historical reasons
eg column id in one db number and in another (newer) number(15). We use for such column
dataset data type mapping as largeint. I think dataset.assign or dataset.gotoCurrent don't take this type mapping in account and i think this is bug.
please modify test so:
Code: Select all
with DsetOrig do begin
connection := UniConnection1;
sql.Text := 'select id,name from test_table';
DataTypeMap.Clear;
DataTypeMap.AddFieldNameRule( 'ID', ftLargeint );
Prepare;
Open;
moveBy( 1 ); // recno is 2
end;
DsetDeriv.Assign( DsetOrig );
DsetDeriv.Open;
DsetDeriv.GotoCurrent( DsetOrig ); // Recno is 1 Error
DsetDeriv stay on record one.
Best regards . Vojslav
Re: TCustomDADataSet.GotoCurrent in version 5.2.7
Posted: Wed 05 Mar 2014 11:41
by AlexP
Even if the ID field type in your sample is changed from Number to Number(15) and DataTypeMapping is used - then anyway, when using GotoCurrent method, DsetDeriv moves to a correct record. The GotoCurrent method calls eventually the Locate method. There may be no key fields (by which the Locate method works) in your tables.
Re: TCustomDADataSet.GotoCurrent in version 5.2.7
Posted: Wed 05 Mar 2014 13:04
by ketas
Hi,
aned why is it in version 5.0.2 other than in 5.2.7? ket
Re: TCustomDADataSet.GotoCurrent in version 5.2.7
Posted: Wed 05 Mar 2014 13:43
by ketas
hi,
i have same keyfield and it do not works.
try in sample add DsetOrig.KeyFields := 'ID';
No success.
Best regards. Vojslav
Re: TCustomDADataSet.GotoCurrent in version 5.2.7
Posted: Thu 06 Mar 2014 09:51
by AlexP
We have reproduced the problem and will investigate the reasons for such behavior.
Re: TCustomDADataSet.GotoCurrent in version 5.2.7
Posted: Wed 26 Mar 2014 15:07
by ketas
Hi,
some news about it? Thanks. Vojslav
Re: TCustomDADataSet.GotoCurrent in version 5.2.7
Posted: Thu 27 Mar 2014 09:22
by AlexP
We have already fixed this problem. The fix will be included to the next version.
Re: TCustomDADataSet.GotoCurrent in version 5.2.7
Posted: Thu 27 Mar 2014 09:35
by ketas
hi,
thanks. vojslav