Topics   All   Mac OS X (Only)   Windows (Only)   Linux (Only, Not)   Crossplatform   Server (Not)   Client   Components   Old   Guides
New in version: 5.0   5.1   5.2   5.3   5.4   6.0   6.1   6.2   6.3   6.4   6.5   7.0   7.1    Statistic  

FM.SQL.Text

Queries text of SQL result.

Component: FM FMSQL
Version: 7.0
Mac OS X: Yes
Windows: Yes
Server: Yes
FileMaker Cloud: Yes

MBS( "FM.SQL.Text"; SQLref { ; firstRow; lastRow; firstCol; lastCol; rowSeparator; colSeparator } )

Parameters

Parameter Description Example value
SQLref The reference number returned by FM.SQL.Execute function. $SQLRef
firstRow Optional
The index of first row.
Default is 0.
0
lastRow Optional
The index of last row.
Default is FM.SQL.RowCount-1.
5
firstCol Optional
The index of first column.
Default is 0.
0
lastCol Optional
The index of last column.
Default is FM.SQL.FieldCount-1.
6
rowSeparator Optional
The row separator.
Default is CR.
Char(13)
colSeparator Optional
The column separator.
Default is tab character.
Char(9)

Result

Returns text or error.

Description

Queries text of SQL result.
You can use this method to quickly get all fields in a given area as text.

Examples

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

See also


FM.SQL.RowCount   -   FM.ScriptIDForScriptName

Feedback: Report problem or ask question.




Links
MBS Real Studio Plugins - Nachhilfe in Kell