OraSetInt Function

Action

Assigns a number value 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.

Include file

Ora.bdh

Syntax

OraSetInt( in cCursor : cursor,
           in sSqlVar : string,
           in nValue  : number,
           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
nValue Number value 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
  var
    nAge  : number;
    sName : string;
  begin
    OraLogon(hConnection, "user", "password", "orclnet2");
    OraOpen(cCursor, hConnection);
    OraParse(cCursor, sqlSelect);
    OraBind(cCursor, ":1", SQLT_INT);
    OraSetInt(cCursor, ":1", 25);
    OraDefine(cCursor, 1, SQLT_CHR, 32);
    OraDefine(cCursor, 2, SQLT_INT);
    OraExec(cCursor);

    while OraFetch(cCursor) do
      sName := OraGetString(cCursor, "1");
      nAge := OraGetInt(cCursor, "2");
      write(sName, 32); write(nAge, 5); writeln;
    end;

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

dclsql
  sqlSelect:
    SELECT * FROM persons WHERE age > :1;

Output

Howard 33Michael 44Bobby 61Sara 38

Sample scripts

OraArrayFetch.bdf, OraSample.bdf, OraLoadPers.bdf