Executes an SQL script from a variable or a file.
function ibec_ExecSQLScript(Connection : variant; SQLScript : string; Options : string; ProgressBlock : variant) : variant;
SQLScript | Script text or name of script file. |
Options | |
ServerVersion | |
StopOnError | |
TransactionParams (TrParams) | This option can be used to specify the initial transaction isolation level for the SQL script. Transaction parameters should be separated with a colon or semicolon: TrParams=“read_committed,rec_version,nowait” |
ProgressBlock | An IBEBlock which will be executed for every progress message generated during script execution. |
ibec_ExecSQLScript executes an SQL script from a variable or a file.
Connection is an active connection created with the ibec_CreateConnection function which will be used while executing a script. If Connection is not specified (NULL) the script must contain the CREATE DATABASE or the CONNECT statement, otherwise an exception will be raised.
ibec_ExecSQLScript returns NULL if there were no errors while executing a script. Otherwise it returns an error(s) message.
execute ibeblock as begin cbb = 'execute ibeblock (BlockData variant) as begin sMessage = BlockData; if (sMessage is not null) then ibec_Progress('SQL Script: ' + sMessage); end'; db = ibec_CreateConnection(__ctFirebird, ...); try Scr = 'INSERT INTO MYTABLE (ID, DATA) VALUES (1, 'Bla-bla'); ' + 'INSERT INTO MYTABLE (ID, DATA) VALUES (2, 'Bla-bla'); ' + 'COMMIT;'; ibec_ExecSQLScript(db, Scr, 'ServerVersion=FB21; StopOnError=FALSE', cbb); ... ibec_ExecSQLScript(db, 'D:\Scripts\CheckData.sql', 'ServerVersion=FB21', null); finally ibec_CloseConnection(db); end end