I use Oracle 12 , with Delphi 10.4 and Firedac to save the cube file and Schema File , on CLob database Field.
TABLE SCRIPT
Create Table TabelaSchema
(
ID Number not null,
usuario varchar2(15) not null,
nomearquivo varchar2(100) not null,
Arquivo_Schema clob not null,
DATAGRAVACAO date not null,
TIPO varchar2(1)
) TABLESPACE ....(so here i don´t know the name you can use)
alter table TabelaSchema
add constraint PK_ID primary key (ID)
using index;
create sequence SQ_TabelaSchema
minvalue 1
maxvalue 99999999999999999999999
start with 1
increment by 1;
---------------------------------------------------------------------
Procedure TFrm.SalvarCubo;
var Qry_Leitura,Qry : TFDQuery;
arq: TextFile;
vNomeArquivo: string;
begin
if SaveDialogCube.Execute then
fcxCube.SaveToFile(SaveDialogCube.fileName);
vNomeArquivo := vcUsuario + '_' + Copy(SaveDialogCube.fileName,LastDelimiter('\', SaveDialogCube.fileName)+1,50);
end
else
exit;
Qry:= TFDQuery.Create(nil);
If not vcDatabase.InTransaction then
vcDatabase.StartTransaction;
try
Qry.ConnectionName := cDataBaseName;
Qry.SQL.Clear;
Qry.SQL.Add('INSERT INTO TabelaSchema(ID, USUARIO , NOMEARQUIVO, ARQUIVO_SCHEMA, DATAGRAVACAO, TIPO) VALUES');
Qry.SQl.Add('(SQ_table.NextVal, :P_USUARIO, :P_NOMEARQUIVO , :P_ARQUIVO_SCHEMA, :P_DATAGRAVACAO, :P_TIPO)');
Qry.ParamByName('P_USUARIO').AsString:= vcUsuario;
Qry.ParamByName('P_NOMEARQUIVO').AsString:= vNomeArquivo;
Qry.ParamByName('PARQUIVOSCHEMA' ).LoadFromFile(SaveDialogCube.fileName, ftOraClob);
Qry.ParamByName('P_DATAGRAVACAO').AsDateTime:= Now;
Qry.ParamByName('P_TIPO').AsString:= 'C';
Qry.ExecSQL;
except on E: Exception do
ShowMessage(e.Message);
vcDatabase.Rollback;
end;
End;
if vcDatabase.InTransaction then
vcDatabase.Commit;
finally
Qry.Free;
Comments
I use Oracle 12 , with Delphi 10.4 and Firedac to save the cube file and Schema File , on CLob database Field.
TABLE SCRIPT
Create Table TabelaSchema
(
ID Number not null,
usuario varchar2(15) not null,
nomearquivo varchar2(100) not null,
Arquivo_Schema clob not null,
DATAGRAVACAO date not null,
TIPO varchar2(1)
) TABLESPACE ....(so here i don´t know the name you can use)
alter table TabelaSchema
add constraint PK_ID primary key (ID)
using index;
create sequence SQ_TabelaSchema
minvalue 1
maxvalue 99999999999999999999999
start with 1
increment by 1;
---------------------------------------------------------------------
Procedure TFrm.SalvarCubo;
var Qry_Leitura,Qry : TFDQuery;
arq: TextFile;
vNomeArquivo: string;
begin
if SaveDialogCube.Execute then
begin
fcxCube.SaveToFile(SaveDialogCube.fileName);
vNomeArquivo := vcUsuario + '_' + Copy(SaveDialogCube.fileName,LastDelimiter('\', SaveDialogCube.fileName)+1,50);
end
else
exit;
Qry:= TFDQuery.Create(nil);
If not vcDatabase.InTransaction then
vcDatabase.StartTransaction;
try
Qry.ConnectionName := cDataBaseName;
Qry.SQL.Clear;
Qry.SQL.Add('INSERT INTO TabelaSchema(ID, USUARIO , NOMEARQUIVO, ARQUIVO_SCHEMA, DATAGRAVACAO, TIPO) VALUES');
Qry.SQl.Add('(SQ_table.NextVal, :P_USUARIO, :P_NOMEARQUIVO , :P_ARQUIVO_SCHEMA, :P_DATAGRAVACAO, :P_TIPO)');
try
Qry.ParamByName('P_USUARIO').AsString:= vcUsuario;
Qry.ParamByName('P_NOMEARQUIVO').AsString:= vNomeArquivo;
Qry.ParamByName('PARQUIVOSCHEMA' ).LoadFromFile(SaveDialogCube.fileName, ftOraClob);
Qry.ParamByName('P_DATAGRAVACAO').AsDateTime:= Now;
Qry.ParamByName('P_TIPO').AsString:= 'C';
Qry.ExecSQL;
except on E: Exception do
begin
ShowMessage(e.Message);
vcDatabase.Rollback;
end;
End;
if vcDatabase.InTransaction then
vcDatabase.Commit;
finally
Qry.Free;
end;
end;