OraSetPieces 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

Ora.bdh

Syntax

OraSetPieces( in cCursor     : cursor,
              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 OraOciError function to retrieve the Oracle OCI error code

Parameter Description
cCursor Cursor associated with a database connection
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
  hConnection : number;
  cCursor     : cursor;

dcltrans
  transaction TMain
  begin
    OraLogon(hConnection, "user", "password", "orclnet2");
    OraOpen(cCursor, hConnection);
    OraParse(cCursor, sqlInsert);
    OraBind(cCursor, ":name", SQLT_STR, 32);
    OraBind(cCursor, ":data", SQLT_LBI, 4096, 64000, ORA_PIECEWISE);
    OraSetString(cCursor, ":name", "Sunset");
    OraSetPieces(cCursor, ":data", "TestData.dat");
    OraExec(cCursor);

    OraClose(cCursor);
    OraLogoff(hConnection);
  end TMain;

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

See also

Wrapped Oracle function: ogetpi, osetpi