Page 1 of 1

BLOB Field HELP

Posted: Thu 27 Apr 2006 16:24
by GHill
I am using Delphi 7 with ODAC 5.70.0.30 13.04.06 and .NET option
This is the code I am using:

q := 'insert into tblaudio (dtbegintime,dtendtime,szsector,szFacid,blobsound) ';
q := q + 'VALUES ';
q := q + '(:pdtbegintime,:pdtendtime,:pszsector,:pszFacid,:pblobsound)';
OraSoundQuery.SQL.clear;
OraSoundQuery.SQL.Text := q;
OraSoundQuery.ParamByName('pszFacid').Asstring := FacilityEdit.text;
OraSoundQuery.ParamByName('pszsector').Asstring := sectorcombo.text;
OraSoundQuery.ParamByName('pdtbegintime').Asdatetime := G_StartTime;
OraSoundQuery.ParamByName('pdtendtime').Asdatetime := G_EndTime;

OraSoundQuery.ParamByName('pblobsound').ParamType := ptInput; //to transfer lob data to oracle
OraSoundQuery.ParamByName('pblobsound').AsOraBlob.OCISvcCtx := OraSession1.OCISvcCtx;
OraSoundQuery.ParamByName('pblobsound').AsOraBlob.LoadFromFile(audiocapture1.audiofilename);
OraSoundQuery.ParamByName('pblobsound').AsOraBlob.WriteLob; I get the error "LOB IS NOT ALLOCATED"
OraSoundQuery.Execute;

I have NEVER used a BLOB field for anything. Can anyone point me in the right direction?


Thanks

Posted: Thu 27 Apr 2006 16:33
by Legion
Read ODAC help -> "Using ODAC" -> "Working with BLOB and CLOB data types"

Posted: Thu 27 Apr 2006 17:14
by GHill
Well....that may make sense to longtime ORACLE users but it made VERY little since to me. I do not have access to the ORACLE server itself. Everything I do has to be done thru ODAC and DELPHI.

Can you give me a COMPLETE example of DELPHI ONLY code that will work.

Thanks

Posted: Thu 27 Apr 2006 17:18
by GHill
Also....the table definitions are already created, so I can't change/create tables.

Posted: Fri 28 Apr 2006 07:20
by Challenger
Try to use the following code:

Code: Select all

q := 'insert into tblaudio (dtbegintime,dtendtime,szsector,szFacid,blobsound) '; 
q := q + 'VALUES ';
q := q + '(:pdtbegintime,:pdtendtime,:pszsector,:pszFacid, empty_blob()) ';
q := q + ' returning blobsound into :pblobsound';
OraSoundQuery.SQL.Text := q;
OraSoundQuery.ParamByName('pszFacid').Asstring := FacilityEdit.text; 
OraSoundQuery.ParamByName('pszsector').Asstring := sectorcombo.text; 
OraSoundQuery.ParamByName('pdtbegintime').Asdatetime := G_StartTime; 
OraSoundQuery.ParamByName('pdtendtime').Asdatetime := G_EndTime; 

OraSoundQuery.ParamByName('pblobsound').ParamType := ptInput;
OraSoundQuery.ParamByName('pblobsound').AsBlobLocator.LoadFromFile(audiocapture1.audiofilename); 
OraSoundQuery.Execute;

Posted: Fri 28 Apr 2006 13:20
by GHill
OUTSTANDING challenger !!!!!!!!!!

Thank you VERY MUCH!