BLOB Field HELP

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
GHill
Posts: 12
Joined: Thu 02 Jun 2005 14:19

BLOB Field HELP

Post by GHill » Thu 27 Apr 2006 16:24

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

Legion
Posts: 30
Joined: Wed 01 Jun 2005 15:38
Location: Russia

Post by Legion » Thu 27 Apr 2006 16:33

Read ODAC help -> "Using ODAC" -> "Working with BLOB and CLOB data types"

GHill
Posts: 12
Joined: Thu 02 Jun 2005 14:19

Post by GHill » Thu 27 Apr 2006 17:14

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

GHill
Posts: 12
Joined: Thu 02 Jun 2005 14:19

Post by GHill » Thu 27 Apr 2006 17:18

Also....the table definitions are already created, so I can't change/create tables.

Challenger
Devart Team
Posts: 925
Joined: Thu 17 Nov 2005 10:53

Post by Challenger » Fri 28 Apr 2006 07:20

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;

GHill
Posts: 12
Joined: Thu 02 Jun 2005 14:19

Post by GHill » Fri 28 Apr 2006 13:20

OUTSTANDING challenger !!!!!!!!!!

Thank you VERY MUCH!

Post Reply