Topics
All
MacOS
(Only)
Windows
(Only)
Linux
(Only, Not)
iOS
(Only, Not)
Components
Crossplatform Mac & Win
Server
Client
Old
Deprecated
Guides
Examples
Videos
New in version:
12.1
12.2
12.3
12.4
12.5
13.0
13.1
13.2
13.3
13.4
Statistic
FMM
Blog
Queries text of SQL result.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
FM FMSQL | 7.0 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
Parameter | Description | Example | Flags |
---|---|---|---|
SQLref | The reference number returned by FM.SQL.Execute function. | $SQLRef | |
firstRow | The index of first row. Default is 0. |
0 | Optional |
lastRow | The index of last row. Default is FM.SQL.RowCount-1. |
5 | Optional |
firstCol | The index of first column. Default is 0. |
0 | Optional |
lastCol | The index of last column. Default is FM.SQL.FieldCount-1. |
6 | Optional |
rowSeparator | The row separator. Default is CR. Can be more than one character. |
Char(13) | Optional |
colSeparator | The column separator. Default is tab character. Can be more than one character. |
Char(9) | Optional |
Returns text or error.
Query fields and export as text and CSV:
Set Variable [$sql; Value:MBS( "FM.SQL.Execute"; ""; "select * from Clients")]
If [MBS("IsError")]
Show Custom Dialog ["SQL error"; $sql]
Else
Show Custom Dialog ["SQL result"; "got " & MBS( "FM.SQL.RowCount"; $sql ) &" rows with each " & MBS( "FM.SQL.FieldCount"; $sql ) & " …"]
# Write to text file
Set Variable [$text; Value:MBS( "FM.SQL.Text"; $sql )]
Set Variable [$desktopFolder; Value:MBS( "Folders.UserDesktop" )]
Set Variable [$path; Value:MBS( "Path.AddPathComponent"; $desktopFolder; "fields.txt" )]
Set Variable [$r; Value:MBS( "Text.WriteTextFile"; $text; $path; "UTF8")]
# Write to text file
Set Variable [$text; Value:MBS( "FM.SQL.CSV"; $sql )]
Set Variable [$path; Value:MBS( "Path.AddPathComponent"; $desktopFolder; "fields.csv" )]
Set Variable [$r; Value:MBS( "Text.WriteTextFile"; $text; $path; "UTF8")]
# Cleanup
Set Variable [$r; Value:MBS( "FM.SQL.Release"; $sql )]
End If
This function checks for a license.
Created 8th January 2017, last changed 31st March 2023