简体   繁体   中英

How to Insert Large Binary Data(Above 32KB ) in to oracle table using Procedure / Inline / C#

I am facing issue when I try to upload the data which is more than 32kb size. here is my source.

Query: INSERT ("DllName", "DllData", "DllVersion", "AssemblyId") VALUES (v_codepluginname, v_dlldata, v_dllversion, v_assemblyid);

v_dlldata is the Binary Data. Data type in the DB is BLOB

I am using Oracle.ExecuteNonQuery();

Please let me if there is any solution.

Our code probably uses implicit conversion to RAW datatype.

Oracle LOBS have different semantics, than other dattypes. And also Oracle treates them differently than other databases. Imagine that a BLOB is in fact a file handle (it's called LOB locator) created on the side of the DB server. Create a procedure, which creates an empty LOB, and then it returns it to a caller:

create or replace procedure store_lob (i_DllName in VARCHAR2, o_DllData in out BLOB)
as
begin 
  insert into t1(DDL_NAME, DDL_DATA) VALUES(i_DDLNAME, EMPTY_BLOB) 
  RETURNING DDR_DATA into o_DDLDate);
end;

Then when our procedure returns, you have a socket, where you can write a file content. You can even start an async thread, and write the file asynchonously, while you use the same db connection for something else. You can append to a lob locator until you issue the commit.

This approach seems to be a little bit over-engeneered, but on the other hand it supports producer-cunsummer design pattern, and no one (neither the app, neither the DB) has to hold the whole file content in a RAM.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM