OraGetFloat Function

Action

Retrieves a floating-point value either from the program variable that is bound with the specified place holder in the SQL statement or PL/SQL block, or from the output variable that is defined for the specified select-list item in the SQL query. This function is used to retrieve values from both scalar and array program variables that are defined for the specified select-list item.

Include file

Ora.bdh

Syntax

OraGetFloat( in cCursor : cursor,
             in sSqlVar : string,
             in nIndex  : number optional): float;

Return value

Retrieved floating-point value

Parameter Description
cCursor Cursor associated with a database connection
sSqlVar

This parameter can be one of the following:

  • the name of the place holder in the SQL statement or PL/SQL block. In this case, the parameter must include the preceding colon identifying it as a place holder

  • the index of the select-list item in the SQL query. Position indices start at 1 for the first (leftmost) select-list item

注: In the latter case, the column number has to be passed to the function as a string.
nIndex

Index or row number (optional). This parameter has to be passed to the function whenever retrieving a value assigned to an array place holder or fetching data from multiple rows. It can be one of the following:

  • the array index of the program variable

  • the row number for the floating-point value in the fetched data

Example

var
  hConnection : number;
  cCursor : cursor;

dcltrans
  transaction TMain
  var
    sName : string;
    fBalance : float;
  begin
    OraLogon(hConnection, "user", "password", "orclnet2");
    OraOpen(cCursor, hConnection);
    OraParse(cCursor, sqlSelect);
    OraBind(cCursor, ":1", SQLT_FLT);
    OraSetFloat(cCursor, ":1", 2000.0);
    OraDefine(cCursor, 1, SQLT_CHR, 32);
    OraDefine(cCursor, 2, SQLT_FLT);
    OraExec(cCursor);

    while OraFetch(cCursor) do
      sName := OraGetString(cCursor, "1");
      fBalance := OraGetFloat(cCursor, "2");
      write(sName, 32); write(fBalance); writeln;
    end;
    
    OraClose(cCursor);
    OraLogoff(hConnection);
  end TMain;

dclsql
  sqlSelect:
    SELECT * FROM accounts WHERE balance > :1;

Output

Bob 13864.220000Pamela 4492.090000Richard 7309.580000

Sample scripts

OraArrayFetch.bdf, OraSample.bdf