beckhoff TS6420 — 8.6 Stored Procedures with MS SQL

Samples nErrId=> nErrid); (*-------------------------------------------------------------------------*) (*Write the record to the database*) FB_DBRecordInsert1( sNetID:= , hDBID:= 1, sInsertCmd:= sInsertString, bExecute:= bStartstopInsert, tTimeout:= T#15s, bBusy=> bBusyInsert, bError=> bErrInsert, nErrID=> nErridInsert, sSQLState=> stSQLStateInsert); eSQL_SELECT:

(*Read one record from the database*) FB_DBRecordSelect1( sNetID:= , hDBID:= 1, sSelectCmd:= 'SELECT * FROM tbl_Test', nRecordIndex:= nRecIndex, cbRecordSize:= SIZEOF(stRecord), pDestAddr:= ADR(stRecord), bExecute:= bStartstopSelect, tTimeout:= T#15s, bBusy=> bBusySelect, bError=> bErrorSelect, nErrID=> nErrIDSelect, sSQLState=> stSQLStateSelect, nRecords=> nRecordCount); END_CASE Screenshot tbl_Test: 8.6 Stored Procedures with MS SQL No "stored procedures" can be generated or configurated with the Database Server. Stored procedures can be carried out with the function blocks FB_DBStoredProcedures and FB_DBStoredProceduresRecordReturn from the version 1.0.13 on.

With the help of these function blocks parameters can be declared as INPUT, OUTPUT or INOUT and can be passed over to the stored procedures. So complex SQL-commands can be pre-programmed at the database server and only need to be triggered by the TwinCAT Database Server. Download "Example with stored procedures" https://infosys.beckhoff.com/content/1033/tcdbserver/ Resources/11407907595/.zip TS6420 115 Version: 1.2