BLOB With VirutalQuery Oracle
Hi,
I need to use VitrualQuery to transfert Tables, table with clob et blob, but if I done the folowing code. With Postgres at the end Table2.Memo is filled by with Oracle is Empty. If I execute 'INSERT INTO TABLE2 SELECT * FROM TABLE1' in sqlplus it Works.
Can you help please.
- procedure TFichePrincipale.Button1Click(Sender: TObject);
var
AQ: TUniQuery;
T1: TUniTable;
T2: TUniTable;
VQ: TVirtualQuery;
begin
AQ := TUniQuery.Create(nil);
AQ.Connection := FicheModuleDonnees.Connection;
try
AQ.Sql.Text := 'DROP TABLE TABLE1';
AQ.ExecSQL;
except on Exception do
end;
try
AQ.Sql.Text := 'DROP TABLE TABLE2';
AQ.ExecSQL;
except on Exception do
end;
if FicheModuleDonnees.Connection.ProviderName = 'Oracle' then
begin
AQ.Sql.Text := 'CREATE TABLE TABLE1(ID VARCHAR2(1),MEMO BLOB)';
AQ.ExecSQL;
AQ.Sql.Text := 'CREATE TABLE TABLE2(ID VARCHAR2(1),MEMO BLOB)';
AQ.ExecSQL;
end
else
begin
AQ.Sql.Text := 'CREATE TABLE TABLE1(ID VARCHAR(1),MEMO BYTEA)';
AQ.ExecSQL;
AQ.Sql.Text := 'CREATE TABLE TABLE2(ID VARCHAR(1),MEMO BYTEA)';
AQ.ExecSQL;
end;
AQ.Sql.Text := 'INSERT INTO TABLE1 (ID,MEMO) VALUES (:ID,:MEMO)';
AQ.Params[0].DataType := ftString;
AQ.Params[1].DataType := ftBlob;
AQ.Params[0].AsString := '1';
AQ.Params[1].LoadFromFile('E:\Temp\a.xlsx',ftBlob);
AQ.ExecSQL;
T1 := TUniTable.Create(nil);
T1.Connection := FicheModuleDonnees.Connection;
T1.TableName := 'TABLE1';
T1.Open;
T2 := TUniTable.Create(nil);
T2.Connection := FicheModuleDonnees.Connection;
T2.TableName := 'TABLE2';
T2.Open;
VQ := TVirtualQuery.Create(nil);
VQ.SourceDataSets.Add(T1, '', 'TABLE1');
VQ.SourceDataSets.Add(T2, '', 'TABLE2');
VQ.Sql.Text := 'INSERT INTO TABLE2 SELECT * FROM TABLE1';
VQ.ExecSQL;
FreeAndNil(AQ);
FreeAndNil(T1);
FreeAndNil(T2);
FreeAndNil(VQ);
end;