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