Top | Previous | Next |
system.db.runSFPrepUpdate |
Description Runs a prepared statement query through the store and forward system and to multiple datasources at the same time. Prepared statements differ from regular queries in that they can use a special placeholder, the question-mark character (?) in the query where any dynamic arguments would go, and then use an array of values to provide real information for those arguments. Make sure that the length of your argument array matches the number of question-mark placeholders in your query. This call should be used for UPDATE, INSERT, and DELETE queries.
This is extremely useful for two purposes:
This function accepts keyword-style invocation. See also: Functions / Keyword Invocation
Syntax system.db.runSFPrepUpdate(query, args, datasources) Parameters String query - A query (typically an UPDATE, INSERT, or DELETE) to run as a prepared statement, with placeholders (?) denoting where the arguments go. Object[] args - A list of arguments. Will be used in order to match each placeholder (?) found in the query. String[] datasources - List of datasources to run the query through. Returns boolean - Returns true if successfully sent to store-and-forward system. Scope All Examples Example 1: Run through single datasource
print system.db.runSFPrepUpdate("INSERT INTO recipes (name, sp1, sp2, sp3) " + "VALUES (?,?,?,?)", ['A Name', 1032, 234, 1], datasources=["MySQLDatasource"])
Example 2: Run through two datasources
print system.db.runSFPrepUpdate("INSERT INTO recipes (name, sp1, sp2, sp3) " + "VALUES (?,?,?,?)", ['A Name', 1032, 234, 1], datasources=["MySQLDatasource", "SQLServerDatasource"]) |