English 中文(简体)
• 如何利用互联网和Lob 定位器撰写LONG RAW数据?
原标题:How to write LONG RAW data using OCI and Lob locator?

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;

使用龙虾收集长的原始数据吗? 如何?

问题回答

LONG RAW has been deprecated since Oracle 8, IIRC. There is no advantage in using a LONG RAW column, and you can easily convert them using the TO_LOB function (if you can, of course). There was exactly a 2000 byte limit when loading a raw column through a raw variable or something alike, and I don t know if LOB locators were ever designed to work with RAW types, I guess they could perform some implicit translation, AFAIK RAW types were used without the LOB interface - and I would not mess things together.

您应使用QT。 相反,低排放量数据。

因此:

    ftBlob: begin
      oLength := Length(VData);
      if oLength<2000 then begin
        VDBTYPE := SQLT_BIN;
        oData := pointer(VData);
      end else begin
        VDBTYPE := SQLT_LVB;
        oData := Pointer(PtrInt(VData)-sizeof(Integer));
        Inc(oLength,sizeof(Integer));
      end;
    end;




相关问题
Export tables from SQL Server to be imported to Oracle 10g

I m trying to export some tables from SQL Server 2005 and then create those tables and populate them in Oracle. I have about 10 tables, varying from 4 columns up to 25. I m not using any constraints/...

Connecting to Oracle 10g with ODBC from Excel VBA

The following code works. the connection opens fine but recordset.recordCount always returns -1 when there is data in the table. ANd If I try to call any methods/properties on recordset it crashes ...

How to make a one to one left outer join?

I was wondering, is there a way to make a kind of one to one left outer join: I need a join that matches say table A with table B, for each record on table A it must search for its pair on table B, ...

Insert if not exists Oracle

I need to be able to run an Oracle query which goes to insert a number of rows, but it also checks to see if a primary key exists and if it does, then it skips that insert. Something like: INSERT ALL ...

How can I store NULLs in NOT NULL field?

I just came across NULL values in NOT-NULL fields in our test database. How could they get there? I know that NOT-NULL constraints can be altered with NOVALIDATE clause, but that would change table s ...

Type reference scope

I m studying databases and am currently working on a object-relational DB project and I ve encountered a small problem with the number of possible constraints in an object table. I m using "Database ...

OracleParameter and DBNull.Value

we have a table in an Oracle Database which contains a column with the type Char(3 Byte). Now we use a parameterized sql to select some rows with a DBNull.Value and it doesn t work: OracleCommand ...

热门标签