| Components | All | New | MacOS | Windows | Linux | iOS | ||||
| Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old | |
SQL.SetConnectionOption
Sets a string value of a specific connection or command option.
| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
| SQL | 2.6 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
Parameters
| Parameter | Description | Example |
|---|---|---|
| Connection | The connection reference number gained with SQL.NewConnection. | $Connection |
| Key | A string key of the connection or command option. | "" |
| Value | The new option value. | "" |
Result
Returns "OK" or error message.
Description
Sets a string value of a specific connection or command option.Call this method to set value(s) of server specific connection or command options. See Server specific notes.
SetOption method is safe to use in cross-server applications. An option related to a particular server does not affect others.
see also:
https://www.sqlapi.com/ApiDoc/class_s_a_connection.html
We have a collection of library files here:
https://www.monkeybreadsoftware.com/filemaker/files/Libs/
Examples
All: Requests 100 rows to be prefetched:
# will propagate down to all commands on that connection.
CubeSQL: Set the path to DLL for Windows:
CubeSQL: Enable SSL connection:
MBS( "SQL.SetConnectionOption"; $Connection; "SSLCertificatePath"; $path )
CubeSQL: Set connection timeout for CubeSQL:
DB2: Set path for libraries:
Informix: Set path for libraries on Windows:
InterBase: Set Firebird libraries:
MySQL: Set path to library on Windows:
Set Variable [ $r; MBS( "SQL.SetConnectionOption"; $Connection; "MYSQL.LIBS"; "c:\MySQL\libmySQL.dll" ) ]
MySQL: Set path to library on macOS:
MySQL: Set path for Ubuntu 22:
"MYSQL.LIBS"; "/usr/lib/aarch64-linux-gnu/libmysqlclient.so.21" ) ]
# needs mysql client library package installed. Your version may not be 21 for the library!
MySQL: Enable multi statements and results explicitly for MySQL:
MBS( "SQL.SetConnectionOption"; $Connection; "CLIENT_MULTI_RESULTS"; "true" )
MySQL: Set Timeout options:
MBS( "SQL.SetConnectionOption"; $Connection; "MYSQL_OPT_READ_TIMEOUT"; 10 )
MBS( "SQL.SetConnectionOption"; $Connection; "MYSQL_OPT_WRITE_TIMEOUT"; 10 )
MySQL: Store RecordSet locally:
MySQL: Set SSL Cipher:
MySQL: Enable SSL:
MBS( "SQL.SetConnectionOption"; $Connection; "MYSQL_SSL_CERT"; "/Users/cs/Desktop/cert.pem" ) &
MBS( "SQL.SetConnectionOption"; $Connection; "MYSQL_SSL_CA"; "/Users/cs/Desktop/cacert.pem" ) &
MBS( "SQL.SetConnectionOption"; $Connection; "MYSQL_SSL_CAPATH"; "" ) &
MBS( "SQL.SetConnectionOption"; $Connection; "MYSQL_SSL_CIPHER"; "DHE-RSA-AES256-SHA" )
// all options optional, but you need at least one set to activate SSL.
MySQL: Enable SSL for MySQL or MariaDB:
Set Variable [ $sslPath ; Value: MBS( "Path.AddPathComponent"; $appPath ; "cacert.pem") ]
Set Variable [ $result ; Value: MBS("SQL.SetConnectionOption"; $$Connection; "MYSQL_SSL_CA"; $sslPath) ]
# cipher to use
Set Variable [ $result ; Value: MBS("SQL.SetConnectionOption"; $$Connection; "MYSQL_SSL_CIPHER"; "DHE-RSA-AES256-SHA") ]
# require SSL
Set Variable [ $result ; Value: MBS("SQL.SetConnectionOption"; $$Connection; "MYSQL_OPT_SSL_MODE"; "SSL_MODE_REQUIRED") ]
MySQL: Write library to disk from container and initialize:
Set Variable [$SerialNumber; Value:""]
# where we store the library file
Set Variable [$tempFolder; Value:MBS( "Folders.UserTemporary" )]
If [MBS( "IsMacOS" )]
# library for Mac from Container
Set Variable [$container; Value:MySQL::MySQLLibMacContainer]
Set Variable [$filename; Value:"libmysqlclient.dylib"]
Else If [MBS( "IsWindows" )]
# library for Win from Container
Set Variable [$container; Value:MySQL::MySQLLibWinContainer]
Set Variable [$filename; Value:"libmysqlclient.dll"]
Else
Exit Script []
End If
Set Variable [$filepath; Value:MBS( "Path.AddPathComponent"; $tempFolder; $filename)]
# write file
Set Variable [$r; Value:MBS( "Files.WriteFile"; $container; $filepath)]
If [$r ≠ "OK"]
Show Custom Dialog ["Writing file failed"; $r]
End If
# now initialize
Set Variable [$r; Value:MBS( "SQL.SetConnectionOption"; $connection; "MYSQL.LIBS"; $filepath)]
If [$r ≠ "OK"]
Show Custom Dialog ["SQL initialization failed"; $r]
End If
MySQL: Set SSL Mode:
// Valid values: "SSL_MODE_DISABLED" , "SSL_MODE_PREFERRED" , "SSL_MODE_REQUIRED" , "SSL_MODE_VERIFY_CA" , "SSL_MODE_VERIFY_IDENTITY"
MySQL: Set TLS Version:
MySQL: Enable reconnect:
ODBC: Set name of DLL for Windows:
ODBC: Set library on MacOS:
ODBC: Set an option we need for connecting ODBC to FileMaker:
// newer plugins automatically set it right when connecting to FileMaker
ODBC: Set timeout property:
Oracle: Set client library path on Windows:
Set Variable [ $r; MBS( "SQL.SetConnectionOption"; $Connection; "OCI8.LIBS"; "c:\ Oracle\oci.dll" ) ]
PostgreSQL: Set path to library on macOS:
PostgreSQL: Set path to library on Linux with Intel CPU:
# may need installation via Terminal: sudo apt-get install libpq5
SQL Server: Set client database provider for Microsoft SQL Server:
MBS( "SQL.SetConnectionOption"; $Connection; "SQLNCLI.LIBS"; "sqlsrv32.dll" )
SQL Server: Connect to Microsoft SQL Server from Mac via FreeTDS library:
#Tell plugin we want to use Microsoft SQL Server via ODBC
Set Variable [$result; Value:MBS("SQL.SetClient"; $Connection; "ODBC")]
#Tell plugin where freetds library is
Set Variable [$path; Value: "/Users/cs/Desktop/libtdsodbc.dylib"]
#Connect to database
Set Variable [$result; Value:MBS("SQL.Connect"; $Connection; "DRIVER={" & $path & "};Server=192.168.2.32;UId=SA;PWD=test;Database=test;TDS_VERSION=7.2;Port=1433")]
# or TDS_VERSION=8.0;
If [$result ≠ "OK"]
Show Custom Dialog ["Error: " & $result]
Set Variable [$result; Value:MBS("SQL.FreeConnection"; $Connection)]
Halt Script
End If
SQLBase: Set path to libraries:
SQLite: Set library path for macOS:
SQLite: Set flag to open database file read only:
Sybase: Set database libraries:
MBS( "SQL.SetConnectionOption"; $Connection; "SYBCOMN.LIBS"; "/sybase/libsybcomn.so" )
MBS( "SQL.SetConnectionOption"; $Connection; "SYBTCL.LIBS"; "/sybase/libsybtcl.so" )
MBS( "SQL.SetConnectionOption"; $Connection; "SYBCT.LIBS"; "/sybase/libsybct.so" )
MBS( "SQL.SetConnectionOption"; $Connection; "SYBCS.LIBSS"; "/sybase/libsybcs.so" )
Set ODBC libraryies to load Actual tech connection library:
DuckDB: Set path to library:
// on macOS with homebrew used to get the library with duckdb package.
See also
- Folders.UserTemporary
- IsWindows
- Path.AddPathComponent
- Process.SetDllDirectory
- SQL.Connect
- SQL.FreeConnection
- SQL.GetConnectionOption
- SQL.GetConnectionOptions
- SQL.NewCommand
- SQL.SetClient
Release notes
- Version 14.5
- Added MYSQL_OPT_LOCAL_INFILE option for SQL.SetConnectionOption for use with MySQL connections.
- Version 9.2
- Changed SQL.SetConnectionOption to pass more options to commands for MS SQL: SQL_ATTR_CURSOR_TYPE, SQL_ATTR_QUERY_TIMEOUT, SQL_ATTR_CONCURRENCY, SQL_ATTR_CURSOR_SCROLLABLE and SQL_ATTR_CURSOR_SENSITIVITY.
Example Databases
- SQL in FileMaker/Insert or Update Tests
- SQL to other databases/DuckDB Query
- SQL to other databases/Firebird Query
- SQL to other databases/Microsoft SQL Execute
- SQL to other databases/Microsoft SQL Server Connect
- SQL to other databases/Microsoft SQL Server Query
- SQL to other databases/MySQL Query
- SQL to other databases/ODBC Query
- SQL to other databases/PostgreSQL Query
- SQL to other databases/SQLite blob
Blog Entries
- Connect to DuckDB in FileMaker
- Connect to Postgres in FileMaker
- MBS FileMaker Plugin, version 14.5pr4
- Transactions with SQL functions
- Connect to an external database server in FileMaker
- Using TLS when connecting to MySQL server
- ODBC driver and MBS SQL Functions in FileMaker
- MBS FileMaker Plugin, version 9.2pr1
- Tip of the day: Connect to MySQL and run a query
- SQL Connectivity for FileMaker
FileMaker Magazin
This function is free to use.
Created 18th August 2014, last changed 25th February 2026