Components | All | New | MacOS | Windows | Linux | iOS | ||||
Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old |
SQL.GetFieldAsFloat
Returns field's value as floating point number value; converts if needed.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
SQL | 2.6 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
MBS( "SQL.GetFieldAsFloat"; Command; Field ) More
Parameters
Parameter | Description | Example |
---|---|---|
Command | The command reference number gained with SQL.NewCommand. | $Command |
Field | The name or one based index of the field. | $Field |
Result
Returns number or error message.
Description
Returns field's value as floating point number value; converts if needed.For integer values, you can use SQL.GetFieldAsNumber.
see also:
https://www.sqlapi.com/ApiDoc/class_s_a_field.html
For some databases, you get better precision, if you cast/convert to float data type in the SQL statement.
Examples
Reads floating point value from field TotalSales into variable:
$x = MBS("SQL.GetFieldAsFloat"; $command; "TotalSales")
Reads floating point value from 2nd field into variable:
$x = MBS("SQL.GetFieldAsFloat"; $command; 2)
Read null value as empty, otherwise get floating number:
If(
MBS("SQL.GetFieldIsNull"; $command; "FieldName");
"";
MBS("SQL.GetFieldAsFloat"; $command; "FieldName"))
See also
- SQL.GetFieldAsBoolean
- SQL.GetFieldAsDate
- SQL.GetFieldAsJPEG
- SQL.GetFieldAsNumber
- SQL.GetFieldAsPNG
- SQL.GetFieldAsText
- SQL.GetFieldAsTime
- SQL.GetFieldIsNull
- SQL.GetParamAsFloat
- SQL.NewCommand
Example Databases
This function is free to use.
Created 18th August 2014, last changed 25th February 2021