WagoAppSQL-MsSQL
WagoAppSQL-MsSQL
WagoAppSQL_MsSQL
Release 1.6.2.1
CONTENTS
1 Description 1
3 80 Status 12
3.1 Status (GVL) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.2 eStatus (ENUM) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
4 ParameterList (PARAMS) 16
5 VersionHistory (GVL) 18
6 Library Reference 19
i
CHAPTER
ONE
DESCRIPTION
1
CHAPTER
TWO
InOut:
This structure contains detail informations about each “column” or “data field” in a result set
InOut:
This structure contains the response data of a succesful executed SELECT statement in a raw format. Use func-
tion “MsSql_GetStringValue()” to access and convert raw data into IEC-STRING. Afterwarts use IEC-Convert
functions “STRING_TO_x” to map data to local PLC-Variables.
2
WagoAppSQL_MsSQL, Release 1.6.2.1
Interface variables
Function
This function block is used to send SQL statements, such as:
Function description
Remarks for aSqlStatement: You can modify the “length” and number of elements in aSqlStatement
by the global constants from the ParameterList: | - MSSQL_SQL_UPPER_BOUND: | Defines the Upper-
Bound of aSqlStatement, to provide a SQL statement | as “ARRAY [0..MSSQL_SQL_UPPER_BOUND] OF
STRING(MSSQL_SQL_LENGTH)” | - MSSQL_SQL_LENGTH: | Defines the Size in byte of an array ele-
ment of aSqlStatement, | to provide a SQL statement as “ARRAY [0..MSSQL_SQL_UPPER_BOUND] OF
STRING(MSSQL_SQL_LENGTH)”.
All non numeric SQL param values must be “quoted” with an apostroph(‘). Apostroph(’) is also CoDesys-String-
Start-End-Identifier. To use an apostroph(’) inside a CoDeSys-String type $27 or $’.
Example
Note: This function block must be used in the same task as FbMsSql_Login
Interface variables
Function
This function block is used to set up the connection to a MsSQL-Server
Graphical Illustration
Interface variables
Function
This function block is used to close the connection to a MsSQL-Server
Graphical Illustration
Note: This function block must be used in the same task as FbMsSql_Login
Interface variables
Function
This function block is used to send SQL “SELECT” statements to a server which responds with result sets.
Graphical Illustration
Function description
Error code InvalidResponse indicates a mal formated packet. In this case the function block will close the
connection.
Remarks for aSqlStatement: You can modify the “length” and number of elements in “aSqlStatement”
by the global constants from the ParameterList: | - MSSQL_SQL_UPPER_BOUND: | Defines the Upper-
Bound of aSqlStatement, to provide a SQL statement | as “ARRAY [0..UpperBound] OF STRING(Size)” | -
MSSQL_SQL_LENGTH: | Defines the Size in byte of an array element of aSqlStatement, | to provide a SQL
statement as “ARRAY [0..UpperBound] OF STRING(Size)”.
All non numeric SQL param values must be “quoted” with an apostroph(‘). Apostroph(’) is also CoDesys-String-
Start-End-Identifier. To use an apostroph(’) inside a CoDeSys-String type $27 or $’.
Example
Note: Maximum length for field data is 500 bytes (TEXT, VARCHAR, ..)
2.6 ResultSetHelpers
Interface variables
2.6. ResultSetHelpers 6
WagoAppSQL_MsSQL, Release 1.6.2.1
Function
This function converts the requested field data into a IEC61131 data type BOOL
Graphical Illustration
Function description
Supported: TDS_DATA_BITN(16#68) TDS_DATA_BIT1(16#32)
The following return values may be received 16#00000000 => ‘SUCCESS’ 16#80007001 => ‘PARAM-
ERROR: Invalid param “row” - First row start on index 1 16#80007002 => ‘PARAM-ERROR: Invalid
param “col” - First col start on index 1 16#80007003 => ‘PARAM-ERROR: Requested “row” do not ex-
ist in “stResultSet” 16#80007004 => ‘PARAM-ERROR: Requested “col” do not exist in “stResultSet”
16#80007005 => ‘CONVERT-ERROR: Requested “col.row” contains a NULL-VALUE’ 16#80007006 =>
‘PARAM-ERROR: Requested “col” is not of type “BOOL” 16#80007008 => ‘PARAM-ERROR: Requested
“col” is an unsupported fixed length type
Interface variables
Function
This function convert the requested field data into a IEC61131 data type “ARRAY [] OF BYTE”
Graphical Illustration
Function description
Supported: TDS_DATA_BIGBINARY(16#AD) TDS_DATA_TEXT(16#23)
2.6. ResultSetHelpers 7
WagoAppSQL_MsSQL, Release 1.6.2.1
The following return values may be received: >= 0: SUCCESS, Number of bytes copied <0: ERROR, see be-
low for Details
16#00000000 => ‘SUCCESS’ 16#80007001 => ‘PARAM-ERROR: Invalid param “row” - First row start on
index 1 16#80007002 => ‘PARAM-ERROR: Invalid param “col” - First col start on index 1 16#80007003
=> ‘PARAM-ERROR: Requested “row” do not exist in “stResultSet” 16#80007004 => ‘PARAM-ERROR:
Requested “col” do not exist in “stResultSet” 16#80007005 => ‘CONVERT-ERROR: Requested “col.row”
contains a NULL-VALUE’ 16#80007006 => ‘PARAM-ERROR: Requested “col” of unsupported type
16#8000701C => ‘PARAM-ERROR: Startaddress of byte array “dwAddress” not assigned 16#8000701D
=> ‘PARAM-ERROR: Size of byte array “diSize” not assigned’ 16#8000701E => ‘PARAM-ERROR: Size
of byte array to small’
Interface variables
Function
This function convert the requested field data into a IEC61131 data type DATETIME
Graphical Illustration
Function description
Supported: TDS_DATA_DATETIMEN(16#6F) TDS_DATA_DATETIME8(16#3D)
TDS_DATA_DATETIME4(16#3A)
The following return values may be received 16#00000000 => ‘SUCCESS’ 16#80007001 => ‘PARAM-
ERROR: Invalid param “row” - First row start on index 1 16#80007002 => ‘PARAM-ERROR: Invalid
param “col” - First col start on index 1 16#80007003 => ‘PARAM-ERROR: Requested “row” do not ex-
ist in “stResultSet” 16#80007004 => ‘PARAM-ERROR: Requested “col” do not exist in “stResultSet”
16#80007005 => ‘CONVERT-ERROR: Requested “col.row” contains a NULL-VALUE’ 16#80007006 =>
‘PARAM-ERROR: Requested “col” is not of type “DATETIME” 16#80007008 => ‘PARAM-ERROR: Re-
quested “col” of unsupported type “DATETIME4” 16#80007015 => ‘CONVERT-ERROR: datetime value
points to date before 1970 - Unable to convewrt to IEC-DT’
2.6. ResultSetHelpers 8
WagoAppSQL_MsSQL, Release 1.6.2.1
Interface variables
Function
This function convert the requested field data into a IEC61131 data type DINT
Graphical Illustration
Function description
Supported: TDS_DATA_INTN(16#26)
The following return values may be received 16#00000000 => ‘SUCCESS’ 16#80007001 => ‘PARAM-ERROR:
Invalid param “row” - First row start on index 1 16#80007002 => ‘PARAM-ERROR: Invalid param “col” - First col
start on index 1 16#80007003 => ‘PARAM-ERROR: Requested “row” do not exist in “stResultSet” 16#80007004
=> ‘PARAM-ERROR: Requested “col” do not exist in “stResultSet” 16#80007005 => ‘CONVERT-ERROR: Re-
quested “col.row” contains a NULL-VALUE’ 16#80007006 => ‘PARAM-ERROR: Requested “col” is not of type
“INT” 16#8000700A => ‘PARAM-ERROR: Requested “col” is an unsupported 8byte type
Interface variables
Function
This function convert the requested field data into a IEC61131 data type LREAL
Graphical Illustration
2.6. ResultSetHelpers 9
WagoAppSQL_MsSQL, Release 1.6.2.1
Function description
Supported: TDS_DATA_FLOATN(16#6D), TDS_DATA_FLOAT4(16#3B), TDS_DATA_FLOAT8(16#3E)
The following return values may be received 16#00000000 => ‘SUCCESS’ 16#80007001 => ‘PARAM-ERROR:
Invalid param “row” - First row start on index 1 16#80007002 => ‘PARAM-ERROR: Invalid param “col” - First col
start on index 1 16#80007003 => ‘PARAM-ERROR: Requested “row” do not exist in “stResultSet” 16#80007004
=> ‘PARAM-ERROR: Requested “col” do not exist in “stResultSet” 16#80007005 => ‘CONVERT-ERROR: Re-
quested “col.row” contains a NULL-VALUE’ 16#80007006 => ‘PARAM-ERROR: Requested “col” is not of type
“FLOAT” or “REAL”
Interface variables
Function
This function convert the requested field data into a IEC61131 data type REAL
Graphical Illustration
Function description
Supported: TDS_DATA_FLOATN(16#6D), TDS_DATA_FLOAT4(16#3B), TDS_DATA_FLOAT8(16#3E)
The following return values may be received 16#00000000 => ‘SUCCESS’ 16#80007001 => ‘PARAM-ERROR:
Invalid param “row” - First row start on index 1 16#80007002 => ‘PARAM-ERROR: Invalid param “col” - First col
start on index 1 16#80007003 => ‘PARAM-ERROR: Requested “row” do not exist in “stResultSet” 16#80007004
=> ‘PARAM-ERROR: Requested “col” do not exist in “stResultSet” 16#80007005 => ‘CONVERT-ERROR: Re-
quested “col.row” contains a NULL-VALUE’ 16#80007006 => ‘PARAM-ERROR: Requested “col” is not of type
“FLOAT” or “REAL”
2.6. ResultSetHelpers 10
WagoAppSQL_MsSQL, Release 1.6.2.1
Interface variables
Function
This function converts the requested field data into a IEC61131 data type and returns it as string
Graphical Illustration
Function description
Supported column types: TDS_DATA_NVARCHAR(16#E7) TDS_DATA_BIGVARCHAR(16#A7)
TDS_DATA_NCHAR(16#EF) TDS_DATA_BIGCHAR(16#AF) TDS_DATA_GUID(16#24)
The following return values may be received 16#00000000 => ‘SUCCESS’ 16#80007001 => ‘PARAM-ERROR:
Invalid param “row” - First row start on index 1 16#80007002 => ‘PARAM-ERROR: Invalid param “col” - First col
start on index 1 16#80007003 => ‘PARAM-ERROR: Requested “row” do not exist in “stResultSet” 16#80007004
=> ‘PARAM-ERROR: Requested “col” do not exist in “stResultSet” 16#80007006 => ‘PARAM-ERROR: Re-
quested “col” is not of type “STRING” 16#80007008 => ‘PARAM-ERROR: Requested “col” of currently unsup-
ported type
2.6. ResultSetHelpers 11
12
WagoAppSQL_MsSQL, Release 1.6.2.1
CHAPTER
THREE
80 STATUS
InOut:
FOUR
PARAMETERLIST (PARAMS)
InOut:
16
WagoAppSQL_MsSQL, Release 1.6.2.1
DWORD 40
MSSQL_MAX_ROW_COUNT Defines the maximum number of row
this library
can process.
DWORD 500
MSSQL_MAX_ROW_SIZE Defines the maximum length (size in
this library
can process.
BOOL FALSE
MSSQL_CLEAR_RESULT_SET_BEFORE_USE Clear the “stResultSet” before use(n
used by
func-
tion block
“MsSql_Query”.
DWORD 80
MSSQL_MAX_IDENTIFIER_LENGTH Defines the maximum length (size in
used by
structure
“MsSql_FieldInfo”,
this library
can process.
Must be less
than 250.
INT 10
MSSQL_SQL_UPPER_BOUND Defines the upper bound of “aSqlSta
used by
func-
tion blocks
“MsSql_ExecSql”
and
“MsSql_Query”
to provide
an SQL
statement as
“ARRAY
[0..MSSQL_SQL_UPPER_BOU
OF
STRING(MSSQL_SQL_LENGT
INT 200
MSSQL_SQL_LENGTH Defines the size in byte of an array e
of “aSql-
Statement”,
used by
func-
tion blocks
“MsSql_ExecSql”
and
“MsSql_Query”
17
to provide
an SQL
statement as
CHAPTER
FIVE
VERSIONHISTORY (GVL)
Name Type
WagoSysVersion.ProjectInfo
Info
WagoAppSQL_MsSQL.library
18
CHAPTER
SIX
LIBRARY REFERENCE
CmpErrors2 Interfaces
Library Identification:
Name: CmpErrors2 Interfaces
Version: newest
Company: System
Namespace: CmpErrors
Library Properties:
Standard
Library Identification:
Placeholder: Standard
Default Resolution: Standard, * (System)
Namespace: Standard
Library Properties:
WagoSysBSDSocket
Library Identification:
Placeholder: WagoSysBSDSocket
Default Resolution: WagoSysBSDSocket, * (WAGO)
Namespace: WagoSysBSDSocket
Library Properties:
19
WagoAppSQL_MsSQL, Release 1.6.2.1
WagoSysErrorBase
Library Identification:
Placeholder: WagoSysErrorBase
Default Resolution: WagoSysErrorBase, * (WAGO)
Namespace: WagoSysErrorBase
Library Properties:
Library Parameter:
Parameter: RES_LOG_MAX_ENTRIES = 200
Parameter: RES_LOG_MAX_FILES = 1
Parameter: RES_LOG_MAX_FILESIZE = 2000
Parameter: RES_LOG_NAME = ‘WagoAppResultLogger’
WagoSysVersion
Library Identification:
Name: WagoSysVersion
Version: 1.0.0.0
Company: WAGO
Namespace: WagoSysVersion
Library Properties:
WagoTypesCommon
Library Identification:
Placeholder: WagoTypesCommon
Default Resolution: WagoTypesCommon, * (WAGO)
Namespace: WagoTypes
Library Properties:
Library Parameter:
Parameter: MAX_STRING_LENGTH = 255
Parameter: MAX_WSTRING_LENGTH = 255
20
WagoAppSQL_MsSQL, Release 1.6.2.1
© WAGO GmbH & Co. KG, Germany 2018 – All rights reserved. For the avoidance of doubt, this copyright notice
does not only apply to the information above but also and primarily to the described library itself. Please note
that third-party products are always mentioned without reference to intellectual property rights, including patents,
utility models, designs and trademarks, accordingly the existence of such rights cannot be excluded. WAGO is a
registered trademark of WAGO Verwaltungsgesellschaft mbH.
21