SQL.FetchFirst
--------------

Fetches the first row from a result set.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [SQL](component_SQL.md) | [2.6](newinversion26.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "SQL.FetchFirst"; Command ) 

**MBS**( **"SQL.FetchFirst";** /\* Fetches the first row from a result set. \*/  
**$Command**) /\* The command reference number gained with [SQL.NewCommand](SQLNewCommand.md). \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| Command | The command reference number gained with [SQL.NewCommand](SQLNewCommand.md). | $Command |

### Result

Returns 0, 1 or error message.

### Description

Fetches the first row from a result set.  
  
Use [SQL.FetchPrior](SQLFetchPrior.md), SQL.FetchFirst, [SQL.FetchLast](SQLFetchLast.md) method to fetch rows from the scrollable result set. The scrollable result set option should be set before Command executed (SQLite and InterBase don't support this feature). See server specific notes to discover how SQLAPI supports the scrollable result set for certain DBMS.  
  
To check whether a result set exists use [SQL.isResultSet](SQLisResultSet.md) method.   
Scrolling only works if enabled, so please call [SQL.SetCommandOption](SQLSetCommandOption.md) function to enable it if needed.  
Result is 1 on success or 0 on failure.   
### Examples

Fetch first record:

 MBS ("SQL.FetchFirst"; $Command )  
Requests a scrollable record set:

 MBS ( "[SQL.SetCommandOption](SQLSetCommandOption.md)"; $Command ; "Scrollable"; "True" )  
### See also

- [SQL.FetchLast](SQLFetchLast.md)
- [SQL.FetchPrior](SQLFetchPrior.md)
- [SQL.isResultSet](SQLisResultSet.md)
- [SQL.NewCommand](SQLNewCommand.md)
- [SQL.SetCommandOption](SQLSetCommandOption.md)

This function is free to use.

Created 18th August 2014 , last changed 24th April 2016

  
[SQL.Execute](SQLExecute.md) - [SQL.FetchLast](SQLFetchLast.md)

[HTML Version](SQLFetchFirst.shtml)