OraSetString Function

Action

Assigns a string to the program variable that is bound to the specified place holder in the SQL statement or PL/SQL block. The place holder is identified by the name or the number specified in the SQL statement or PL/SQL block. This function is used to assign values to both scalar and array program variables.

Using this function, any of the following data types can be assigned to the program variable that is bound to the specified place holder:

  • SQLT_STR
  • SQLT_CHR
  • SQLT_VCS
  • SQLT_LVC
  • SQLT_AFC
  • SQLT_AVC
  • SQLT_LNG

Include file

Ora.bdh

Syntax

OraSetString( in cCursor : cursor,
              in sSqlVar : string,
              in sString : string,
              in nIndex  : 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
sString String that is assigned to the program variable that is bound to the specified place holder in the SQL statement or PL/SQL block
nIndex Array index (optional). For array binding operations, this parameter specifies the array index of the program variable

Example

var
  hConnection : number;
  cCursor     : cursor;

dcltrans
  transaction TMain
  begin
    OraLogon(hConnection, "user", "password", "orclnet2");
    OraOpen(cCursor, hConnection);
    OraParse(cCursor, sqlInsert);

    // bind array containing two elements
    OraBind(cCursor, ":name", SQLT_CHR, 32, 2);
    OraBind(cCursor, ":age", SQLT_INT, 0, 2);

    // set values
    OraSetString(cCursor, ":name", "Bob", 1);
    OraSetInt(cCursor, ":age", 25, 1);

    OraSetString(cCursor, ":name", "Marcy", 2);
    OraSetInt(cCursor, ":age", 33, 2);
     
    OraExec(cCursor);
    OraClose(cCursor);
    OraLogoff(hConnection);
  end TMain;

dclsql
  sqlInsert:
    INSERT INTO persons (name, age) VALUES (:name, :age);

Sample scripts

OraArrayFetch.bdf, OraSample.bdf, OraLoadPers.bdf