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


Creates a new command.

Component: SQL
Version: 2.6
Mac OS X: Yes
Windows: Yes
Server: Yes
FileMaker Cloud: Yes

MBS( "SQL.NewCommand"; Connection { ; Command; CommandType; ID } )


Parameter Description Example value
Connection The command reference number gained with SQL.NewConnection. $Connection
Command Optional
This represents command text string (an SQL statement or a stored procedure name). If it is empty string, no command text is associated with the command, and you have to call SQL.SetCommandText method later.
CommandType Optional
Type of a command. Can be CmdSQLStmt, CmdSQLStmtRaw or CmdStoredProc.
ID Optional
The ID to use instead of default one.
Must be unique. If none is provided, the plugin will create one.


Returns command reference number or error message.


Creates a new command.
Don't forget to free command with SQL.FreeCommand.
SQL command reference numbers are starting at 22000 and counting up for each new command.


Creates a new command to create table:

MBS("SQL.NewCommand"; $Connection; "CREATE TABLE Test(FirstName VARCHAR, LastName VARCHAR, Birthday date, NumberOfOrders integer, TotalSales double)")

Run a stored procedure:

# new command for calling our test procedure on a Microsoft SQL Server
Set Variable [$command; MBS( "SQL.NewCommand"; $Connection; "dbo.Test" ) ]
# set a parameter
Set Variable [$r; MBS( "SQL.SetParamAsNumber"; $Command; "Param1"; 7 ) ]
# execute query
Set Variable [$r; MBS( "SQL.Execute"; $Command ) ]
# fetch first record
Set Variable [$r; MBS( "SQL.FetchNext"; $Command ) ]
# get result field
Set Variable [$result; MBS( "SQL.GetFieldAsText"; $Command; 1 ) ]

New command with named parameters:

MBS("SQL.NewCommand"; $Connection; "update Documents set ProductNumber=:ProductNumber, PubOptionNo=:PubOptionNo, DueInStock=:DueInStock, ProductTypeID=:ProductTypeID where DocID=:DocID“ )

See also

SQL.MySQL.InsertID   -   SQL.NewConnection

Feedback: Report problem or ask question.

MBS Realbasic PDF Plugins - Pfarrgemeinde St. Arnulf Nickenich