Ora8SetInt 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

Ora8.bdh

Syntax

Ora8SetInt( in hStmt   : number,
            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 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.
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
  ghEnv0        : number;
  ghError0      : number;
  ghStmt0       : number;
  ghSvcCtx0     : number;

dcltrans
  transaction TMain
  var
    sName : string;
    nAge  : number;
  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, sqlSelect, OCI_NTV_SYNTAX);
     
    Ora8Bind(ghStmt0, ":1", SQLT_INT);
        
    Ora8SetInt(ghStmt0, ":1", 25);
    Ora8Define(ghStmt0, 1, SQLT_CHR, 32);
    Ora8Define(ghStmt0, 2, SQLT_INT);
    Ora8StmtExecute(ghSvcCtx0, ghStmt0);
 
    while Ora8StmtFetch(ghStmt0, 1, 1) do
      sName := Ora8GetString(ghStmt0, "1");
      nAge := Ora8GetInt(ghStmt0, "2");
      write(sName, 32); write(nAge, 5); writeln;
    end;

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

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

Output

Howard 33Michael 44Bobby 61Sara 38