I want to fix zeoslib bug in writing long raw data bug description:
Memo1.Lines.LoadFromFile( c: DbcMetadata.pas ); // file size ~ 170Kb
ZQuery1.SQL.Text := insert into t1(id, b) values(10, :p1) ;
ZQuery1.Params[0].AsBlob := Memo1.Lines.Text;
ZQuery1.ExecSQL;
问题是,只有2000年才装上表的tes。
in
var
sql: string;
Handle: POCIStmt;
ErrorHandle: POCIError;
conn: IZOracleConnection;
FPlainDriver: IZOraclePlainDriver;
BindHandle, buff: Pointer;
Status,buflen: integer;
lob: POCILobLocator;
begin
sql := insert into t1(id, b) values(10, :p1) ;
conn := ZConnection1.DbcConnection as IZOracleConnection;
FPlainDriver := conn.GetPlainDriver;
with TFileStream.Create( c: DbcMetadata.pas , fmOpenRead or fmShareDenyNone) do
begin
buflen := Size;
GetMem(buff, buflen);
ReadBuffer(buff^, buflen);
Free;
end;
AllocateOracleStatementHandles(FPlainDriver, conn, Handle, ErrorHandle);
try
PrepareOracleStatement(FPlainDriver, sql, Handle, ErrorHandle);
Status := FPlainDriver.DescriptorAlloc(conn.GetConnectionHandle, lob,
OCI_DTYPE_LOB, 0, nil);
CheckOracleError(FPlainDriver, conn.GetErrorHandle,
Status, lcOther, Open Large Object );
Status := FPlainDriver.LobCreateTemporary(conn.GetContextHandle,
conn.GetErrorHandle, lob, OCI_DEFAULT, OCI_DEFAULT,
OCI_TEMP_BLOB, True, OCI_DURATION_SESSION);
CheckOracleError(FPlainDriver, conn.GetErrorHandle,
Status, lcOther, Create Large Object );
Status := FPlainDriver.LobOpen(conn.GetContextHandle,
conn.GetErrorHandle, lob, OCI_LOB_READWRITE);
CheckOracleError(FPlainDriver, conn.GetErrorHandle,
Status, lcOther, Open Large Object );
Status := FPlainDriver.LobWrite(conn.GetContextHandle,
conn.GetErrorHandle, lob, buflen, 1,
buff, buflen, OCI_ONE_PIECE, nil, nil, 0, SQLCS_IMPLICIT);
CheckOracleError(FPlainDriver, conn.GetErrorHandle,
Status, lcOther, Write Large Object );
Status := FPlainDriver.LobClose(conn.GetContextHandle,
conn.GetErrorHandle, lob);
CheckOracleError(FPlainDriver, conn.GetErrorHandle,
Status, lcOther, Close Large Object );
Status := FPlainDriver.BindByPos(Handle, BindHandle,
ErrorHandle, 1, @lob, SizeOf(POCILobLocator),
SQLT_BLOB, nil, nil, nil, 0, nil,
OCI_DEFAULT);
CheckOracleError(FPlainDriver, ErrorHandle, Status, lcExecute, sql);
ExecuteOracleStatement(FPlainDriver, conn, sql, Handle, ErrorHandle);
FreeMem(buff);
FPlainDriver.DescriptorFree(lob, OCI_DTYPE_LOB);
finally
FreeOracleStatementHandles(FPlainDriver, Handle, ErrorHandle);
end;
conn.Commit;
使用龙虾收集长的原始数据吗? 如何?