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:
10.1
10.2
10.3
10.4
10.5
11.0
11.1
11.2
11.3
11.4
Statistic
FMM
Blog
Sets parameters based on values in JSON.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
SQL | 10.2 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
Parameter | Description | Example |
---|---|---|
Command | The command reference number gained with SQL.NewCommand. | $Command |
JSON | The JSON object with values for the items. | "{ \"Index\": 123 }" |
Returns OK or error.
Run insert with JSON:
# Create insert command with setting values
Set Variable [ $Command ; Value: MBS("SQL.NewCommand"; $Connection; "INSERT INTO 'Test' (FirstName, LastName, Birthday, NumberOfOrders, TotalSales) VALUES (:FirstName,:LastName,:Birthday,:NumberOfOrders,:TotalSales)") ]
# build some JSON
Set Variable [ $json ; Value: "{}" ]
Set Variable [ $json ; Value: MBS( "JSON.AddStringToObject"; $json; "FirstName"; SQLite fun::FirstName ) ]
Set Variable [ $json ; Value: MBS( "JSON.AddStringToObject"; $json; "LastName"; SQLite fun::LastName ) ]
Set Variable [ $json ; Value: MBS( "JSON.AddStringToObject"; $json; "Birthday"; SQLite fun::Birthday ) ]
Set Variable [ $json ; Value: MBS( "JSON.AddNumberToObject"; $json; "NumberOfOrders"; SQLite fun::NumberOfOrders ) ]
Set Variable [ $json ; Value: MBS( "JSON.AddNumberToObject"; $json; "TotalSales"; SQLite fun::TotalSales ) ]
Set Variable [ $result ; Value: MBS("SQL.SetParamsWithJSON"; $Command; $json) ]
# Run it
Show Custom Dialog [ "JSON" ; MBS( "SQL.GetParamsAsJSON"; $Command ) ]
Set Variable [ $result ; Value: MBS("SQL.Execute"; $Command) ]
# Cleanup
Set Variable [ $result2 ; Value: MBS("SQL.Commit"; $Connection) ]
Set Variable [ $result2 ; Value: MBS("SQL.FreeCommand"; $Command) ]
If [ $result ≠ "OK" ]
Show Custom Dialog [ "Error: " & $result ]
Else
Show Custom Dialog [ "Record exported." ]
End If
Created 11st March 2020, last changed 11st March 2020
SQL.SetParamValues - SQL.isAlive
Feedback: Report problem or ask question.