Ora8SetPieces Function

Action

Assigns any data to the program variable that is bound to the specified place holder in the SQL statement for a piecewise INSERT or UPDATE operation. The place holder is identified by the name or the number specified in the SQL statement.

Include file

Ora8.bdh

Syntax

Ora8SetPieces( in hStmt       : number,
               in sSqlVar     : string,
               in sFilename   : string,
               in nCharacters : number optional,
               in nFirstChar  : number optional,
               in nLastChar   : number optional): boolean;

Return value

  • true if successful

  • false otherwise. In this case, you can use the Ora8OciError function to retrieve the Oracle OCI error code

Parameter Description
hStmt Statement handle.
sSqlVar Name of the place holder in the SQL statement or PL/SQL block. This parameter must include the preceding colon identifying it as a place holder.
sFilename

Name of the file containing the data.

If this parameter is set to NULL, random values are generated. In this case, you must specify the amount of random data to generate. The nFirstChar and the nLastChar parameters let you specify a set of characters used for random data generation.

nCharacters Number of random characters to generate (optional). This parameter has to be passed to the function only if sFilename is set to NULL.
nFirstChar First character belonging to the character set used for random data generation (optional). The default option is to use all characters defined in the ASCII table.
nLastChar Last character belonging to the character set used for random data generation (optional). The default option is to use all characters defined in the ASCII table.

Example

var
  ghEnv0        : number;
  ghError0      : number;
  ghStmt0       : number;
  ghSvcCtx0     : number;

dcltrans
  transaction TMain
  const
    PUBLIC_KEY := "\h59b20094...";
  begin
    Ora8Init(ghEnv0, OCI_DEFAULT);
    Ora8HandleAlloc(ghEnv0, ghError0, OCI_HTYPE_ERROR);
    Ora8Logon(ghEnv0, ghSvcCtx0, "user", "password", "orclnet2");

    Ora8HandleAlloc(ghEnv0, ghStmt0, OCI_HTYPE_STMT);
    Ora8StmtPrepare(ghStmt0, sqlInsert, OCI_NTV_SYNTAX);

    Ora8Bind(ghStmt0, ":name", SQLT_CHR, 32);
    Ora8Bind(ghStmt0, ":key", SQLT_BIN, 64);

    Ora8SetString(ghStmt0, ":name", "Michael");
    Ora8SetPieces(ghStmt0, ":data", "TestData.dat");

    Ora8StmtExecute(ghSvcCtx0, ghStmt0);

    Ora8HandleFree(ghStmt0, OCI_HTYPE_STMT);
    Ora8Logoff(ghSvcCtx0);
    Ora8HandleFree(ghError0, OCI_HTYPE_ERROR);
    Ora8HandleFree(ghEnv0, OCI_HTYPE_ENV);
  end TMain;

dclsql
  sqlInsert:
    INSERT INTO images (name, data) VALUES (:name, :data);