Page 1 of 1
Problem with Oracle Blob Delphi
Posted: Tue 14 Dec 2010 14:34
by allexandr
Hello.
I try insert scaned image into oracle table (Direct connection)
If the file size to 1 MB everything goes well.
and if the amount of more 1MB application just hangs.
Code: Select all
fileName:= extractFilePath(Application.ExeName)+'scan.jpg';
UniStoredProc1.Active:= False;
UniStoredProc1.StoredProcName:= 'CRANDWRBLOB';
UniStoredProc1.Prepare;
UniStoredProc1.Params.ParamByName('b_loc').DataType:= ftOraBlob;
UniStoredProc1.Params.ParamByName('b_loc').LoadFromFile(fileName,ftOraBlob);
UniStoredProc1.Params.ParamByName('nID').AsInteger:= 999;
UniStoredProc1.Params.ParamByName('userID').AsInteger:= 777;
UniStoredProc1.Params.ParamByName('fname').AsString:= 'scan.jpg';
UniStoredProc1.Execute;
thanks in advance for the help
Posted: Wed 15 Dec 2010 08:17
by allexandr
People help.
Posted: Wed 15 Dec 2010 13:09
by bork
Hello
Please try the following code:
Code: Select all
begin
OraSession1.ExecSQL('create or replace PROCEDURE proc_btest_blob (in_param in blob, out_param out blob) ' + #13 +
'AS ' + #13 +
'BEGIN ' + #13 +
' out_param := in_param; ' + #13 +
'END;', []);
OraStoredProc1.Options.TemporaryLobUpdate := true;
OraStoredProc1.Prepare;
OraStoredProc1.ParamByName('in_param').AsOraBlob.LoadFromFile('error.bmp');
OraStoredProc1.ExecProc;
OraStoredProc1.ParamByName('out_param').AsOraBlob.SaveToFile('error2.bmp');
end;
Posted: Thu 16 Dec 2010 07:04
by allexandr
bork wrote:Hello
Please try the following code:
Code: Select all
begin
OraSession1.ExecSQL('create or replace PROCEDURE proc_btest_blob (in_param in blob, out_param out blob) ' + #13 +
'AS ' + #13 +
'BEGIN ' + #13 +
' out_param := in_param; ' + #13 +
'END;', []);
OraStoredProc1.Options.TemporaryLobUpdate := true;
OraStoredProc1.Prepare;
OraStoredProc1.ParamByName('in_param').AsOraBlob.LoadFromFile('error.bmp');
OraStoredProc1.ExecProc;
OraStoredProc1.ParamByName('out_param').AsOraBlob.SaveToFile('error2.bmp');
end;
Hello, i cant yse this code becous i use UniDac. not Odac.
Posted: Thu 16 Dec 2010 07:48
by bork
Sorry. Try the following code for UniDAC:
Code: Select all
begin
UniConnection1.ExecSQL('create or replace PROCEDURE proc_btest_blob (in_param in blob, out_param out blob) ' + #13 +
'AS ' + #13 +
'BEGIN ' + #13 +
' out_param := in_param; ' + #13 +
'END;', []);
UniStoredProc1.SpecificOptions.Values['TemporaryLobUpdate'] := 'True';
UniStoredProc1.Prepare;
UniStoredProc1.ParamByName('in_param').AsBlobRef.LoadFromFile('error.bmp');
UniStoredProc1.ExecProc;
UniStoredProc1.ParamByName('out_param').AsBlobRef.SaveToFile('error2.bmp');
end;
Posted: Thu 16 Dec 2010 08:27
by allexandr
Thanks
Code: Select all
var
bstreem : TFileStream;
X: TBytes;
begin
UniConnection1.ExecSQL('create or replace PROCEDURE proc_btest_blob (in_param in blob, out_param out blob) ' + #13 +
'AS ' + #13 +
'BEGIN ' + #13 +
' out_param := in_param; ' + #13 +
'END;', []);
UniStoredProc1.StoredProcName:= 'proc_btest_blob';
UniStoredProc1.Prepare;
UniStoredProc1.ParamByName('in_param').LoadFromFile('big.jpg',ftOraBlob);
UniStoredProc1.ExecProc;
X:= UniStoredProc1.ParamByName('out_param').AsBlob;
Memo1.Lines.Add(IntToStr(Length(X)));
bstreem:= TFileStream.Create('error1.jpg',fmCreate);
bstreem.Write(X[0],Length(X));
bstreem.Free;
end;
all warks. The matter curves hands DB Admin
Bork Thank you so much