0% found this document useful (0 votes)
88 views

WagoAppSQL-MsSQL

Uploaded by

03avfcs
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
88 views

WagoAppSQL-MsSQL

Uploaded by

03avfcs
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

Documentation of the library

WagoAppSQL_MsSQL
Release 1.6.2.1
CONTENTS

1 Description 1

2 20 Program Organization Units 2


2.1 Data types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2.1.1 typMsSql_Column (STRUCT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2.1.2 typMsSql_ResultSet (STRUCT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2.2 FbMsSql_Execute (FB) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.3 FbMsSql_Login (FB) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.4 FbMsSql_Logout (FB) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.5 FbMsSql_Query (FB) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.6 ResultSetHelpers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.6.1 FuMsSql_GetBOOL (FUN) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.6.2 FuMsSql_GetBYTEARRAY (FUN) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.6.3 FuMsSql_GetDATETIME (FUN) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.6.4 FuMsSql_GetDINT (FUN) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.6.5 FuMsSql_GetLREAL (FUN) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.6.6 FuMsSql_GetREAL (FUN) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.6.7 FuMsSql_GetSTRING (FUN) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

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

This document is automatically generated.


Subject to Changes
WAGO GmbH & Co. KG reserves the right to provide for any alterations or modifications. WAGO GmbH & Co.
KG owns all rights arising from the granting of patents or from the legal protection of utility patents. Third-party
products are always mentioned without any reference to patent rights. Thus, the existence of such rights cannot be
excluded.
Personnel Qualification
All tasks that are carried out with libraries made for CODESYS 3 must only be performed by qualified electrical
specialists instructed in PLC programming according to IEC 61131-3.
All tasks that have an effect on the properties or the behavior of automation hardware or software products must
only be performed by qualified employees with a thorough knowledge of handling the products concerned.
Intended Use of CODESYS 3 Libraries
Libraries created for CODESYS 3 are used to simplify the development of application projects in the IEC 61131-3
programming languages.
For automation tasks, WAGO offers programmable logic controllers in a wide variety of performance classes.
In combination with a wide range of I/O modules, the controllers can process standard types of field signals.
Controllers can be implemented centrally or in decentralized configurations. The controllers offer interfaces for
the most commonly used fieldbuses for use in decentralized configurations. Fieldbus independent I/O modules
are then linked via fieldbus couplers. WAGO controllers offer a runtime environment for user programs called
CODESYS 3. The following programming languages of the IEC 61131-3 standard are available:
• Structured Text (ST)
• Ladder Diagram (LD)
• Function Block Diagram (FBD)
• Instruction List (IL)
• Sequential Function Chart (SFC)
• Continuous Function Chart (CFC)
The individual programming languages can also be combined as required during the development of the software.
A portfolio of prepared libraries can be accessed for many frequently used functions in order to make software
development more efficient. This document provides an overview of the WagoAppSQL_MsSQL that WAGO offers
for CODESYS 3.
Function blocks providing access to a MsSQL database.

1
CHAPTER

TWO

20 PROGRAM ORGANIZATION UNITS

2.1 Data types

2.1.1 typMsSql_Column (STRUCT)

InOut:

Name Type Comment


sName Column name
STRING(MSSQL_MAX_IDENTIFIER_LENGTH)
bType BYTE MSSQL-Data-Type of column
bLenSize UDINT Number of bytes used for Length information
of data
udiLength UDINT Length of data in bytes in a ROW_TOKEN
wFlags WORD
wUDDT WORD User-Defined-Data-Type

This structure contains detail informations about each “column” or “data field” in a result set

2.1.2 typMsSql_ResultSet (STRUCT)

InOut:

Name Type Comment


uiColumnCount
UINT Number of columns in a
dataset
astColumns ARRAY [1..MSSQL_MAX_COLUMN_COUNT] OF Column-Details
typMsSql_Column
uiRowCount UINT Number of datasets in
servers response
abRows ARRAY [1..MSSQL_MAX_ROW_COUNT] OF ARRAY Raw datasets
[0..MSSQL_MAX_ROW_SIZE] OF BYTE

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

2.2 FbMsSql_Execute (FB)

Interface variables

ScopeName Type Comment


In- ARRAY [0..MSSQL_SQL_UPPER_BOUND]
aSqlCommand SQL statement
put OF STRING(MSSQL_SQL_LENGTH)
In- xTrigger BOOL Start execution on a rising edge.
out Will be reset by the function block.
Out- xBusy BOOL Execution in progress
put
Out- xError BOOL Error occured
put
Out- oStatus WagoSysErrorBase.FbResult Detailed Status and error informa-
put tion
Out- sStatus STRING(200) Textual description of current state
put or error

Function
This function block is used to send SQL statements, such as:

INSERT, UPDATE, DELETE, ALTER, DROP, . . .

to a server which does not respond with a result set.


Graphical Illustration

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

Prepare SQL-Insert-Statement asSqlStatement1[0] := ‘INSERT INTO atable ‘; asSqlStatement1[1] := ‘( aBool,


aByte, aWord, aDint, aReal, ‘; asSqlStatement1[2] := ‘ aString, aDT, aTime, aUdint ) ‘; asSqlStatement1[3]
:= ‘VALUES ‘; asSqlStatement1[4] := ‘( TRUE, 17, 32333, 1111111, 1.42, ‘; asSqlStatement1[5] := ‘
$’Hallo$’, $’2010-08-13 11:56:42$’, ‘; asSqlStatement1[6] := ‘ $’13:12:57$’, 62222 )’; asSqlStatement1[7]
:= ‘’; (* End of SQL-Statement ) (*The last element must be empty)

2.2. FbMsSql_Execute (FB) 3


WagoAppSQL_MsSQL, Release 1.6.2.1

Note: This function block must be used in the same task as FbMsSql_Login

2.3 FbMsSql_Login (FB)

Interface variables

Scope Name Type Ini- Comment


tial
In- sHost STRING DNS not yet supported
put uiPort UINT 1433 TCP-Port on which the MsSQL-server is listening,
typ. 1433
sUsernameSTRING Name of database account
sPasswordSTRING Password of database account
sAppName STRING Application name
sLibName STRING Library name
sDatabaseSTRING Name of schema to use initially - Optional param
In- xTrigger BOOL Start execution on a rising edge and reset internally
out when done or on timeout.
Out- xBusy BOOL Busy
put
Out- xError BOOL Error occured
put
Out- oStatus WagoSysErrorBase. Detailed Status and error information
put FbResult
Out- sStatus STRING(200) Textual description of current state or error
put
Out- xConnectedBOOL TRUE: when database connection is established
put

Function
This function block is used to set up the connection to a MsSQL-Server
Graphical Illustration

2.3. FbMsSql_Login (FB) 4


WagoAppSQL_MsSQL, Release 1.6.2.1

2.4 FbMsSql_Logout (FB)

Interface variables

Scope Name Type Comment


Inout xTrigger BOOL Start execution on a rising edge and reset internally when
done or on timeout.
Out- xBusy BOOL Busy
put
Out- xError BOOL Error occured
put
Out- oStatus WagoSysErrorBase. Detailed Status and error information
put FbResult
Out- sStatus STRING(200) Textual description of current state or error
put

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

2.5 FbMsSql_Query (FB)

Interface variables

ScopeName Type Comment


In- ARRAY [0..MSSQL_SQL_UPPER_BOUND]SQL statement
aSqlCommand
put OF STRING(MSSQL_SQL_LENGTH)
In- xTrigger BOOL Start execution on a rising edge and re-
out seted internally when done or on time-
out.
In- typResultSet
typMsSql_ResultSet Query response data
out
Out- xBusy BOOL Busy
put
Out- xError BOOL Error occured
put
Out- oStatus WagoSysErrorBase.FbResult Detailed Status and error information
put
Out- sStatus STRING(200) Textual description of current state or
put error

2.4. FbMsSql_Logout (FB) 5


WagoAppSQL_MsSQL, Release 1.6.2.1

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 $’.

Note: This block must be used in the same task as FbMsSql_Login

Example

(* Prepare SQL-SELECT-Statement *) aSqlStatement1[0] := ‘SELECT * ‘; aSqlStatement1[1] := ‘FROM


tablename ‘; aSqlStatement1[2] := ‘WHERE ‘; aSqlStatement1[3] := ‘ name = $27Meyer$27 ‘; aSqlState-
ment1[4] := ‘’; (* End of SQL-Statement *)

Note: Maximum length for identifiers MSSQL_MAX_IDENTIFIER_LENGTH is 250 bytes

Note: Maximum length for field data is 500 bytes (TEXT, VARCHAR, ..)

2.6 ResultSetHelpers

2.6.1 FuMsSql_GetBOOL (FUN)

Interface variables

Scope Name Type Comment


Return FuMSSQL_GetBOOL DINT
Input iCol INT First col start on index 1
Input iRow INT First row start on index 1
Inout xValue BOOL
Inout typResultSet typMSSQL_ResultSet

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

2.6.2 FuMsSql_GetBYTEARRAY (FUN)

Interface variables

Scope Name Type Comment


Return FuMSSQL_GetBYTEARRAY DINT
Input iCol INT First col start on index 1
Input iRow INT First row start on index 1
Input pAddress POINTER TO DWORD Startaddress of byte array
Input diSize DINT Size of byte array
Inout typResultSet typMSSQL_ResultSet

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’

2.6.3 FuMsSql_GetDATETIME (FUN)

Interface variables

Scope Name Type Comment


Return FuMSSQL_GetDATETIME DINT
Input iCol INT First col start on index 1
Input iRow INT First row start on index 1
Inout dtValue DT Seconds since 01.01.1970
Inout typResultSet typMSSQL_ResultSet

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

2.6.4 FuMsSql_GetDINT (FUN)

Interface variables

Scope Name Type Comment


Return FuMSSQL_GetDINT DINT
Input iCol INT First col start on index 1
Input iRow INT First row start on index 1
Inout diValue DINT
Inout typResultSet typMSSQL_ResultSet

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

2.6.5 FuMsSql_GetLREAL (FUN)

Interface variables

Scope Name Type Comment


Return FuMsSql_GetLREAL DINT
Input iCol INT First col start on index 1
Input iRow INT First row start on index 1
Inout lrValue LREAL
Inout typResultSet typMSSQL_ResultSet

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”

2.6.6 FuMsSql_GetREAL (FUN)

Interface variables

Scope Name Type Comment


Return FuMSSQL_GetREAL DINT
Input iCol INT First col start on index 1
Input iRow INT First row start on index 1
Inout rValue REAL
Inout typResultSet typMSSQL_ResultSet

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

2.6.7 FuMsSql_GetSTRING (FUN)

Interface variables

Scope Name Type Comment


Return FuMsSql_GetSTRING DINT
Input iCol INT First col start on index 1
Input iRow INT First row start on index 1
Inout sValue STRING(500)
Inout typResultSet typMSSQL_ResultSet

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

3.1 Status (GVL)

ScopeName Type Initial


Con- AR- [STRUCT(ID := eStatus.OK, Severity := WagoTypesError-
Sta-
stant RAY Base.WagoTypes.eSeverity.info, text := ‘OK’), STRUCT(ID := eS-
tusMsSql
[0..25] tatus.NotConnectedWithDataBase, Severity := WagoTypesError-
OF Base.WagoTypes.eSeverity.error, text := ‘Not connected with data
Wag- base server’), STRUCT(ID := eStatus.InvalidResponse, Severity :=
o- WagoTypesErrorBase.WagoTypes.eSeverity.error, text := ‘Invalid or
Type- unexpected response’), STRUCT(ID := eStatus.Timeout, Severity :=
sEr- WagoTypesErrorBase.WagoTypes.eSeverity.error, text := ‘Timeout’),
ror- STRUCT(ID := eStatus.ErrorMessage, Severity := WagoTypesError-
Base.typResultItem
Base.WagoTypes.eSeverity.error, text := ‘Error message from server’),
STRUCT(ID := eStatus.ResultSetMoreColumn, Severity := WagoTypesEr-
rorBase.WagoTypes.eSeverity.error, text := ‘Result set has more columns
then defined ‘), STRUCT(ID := eStatus.NoLoginAckToken, Severity :=
WagoTypesErrorBase.WagoTypes.eSeverity.error, text := ‘Did not receive
LOGINACK TOKEN’), STRUCT(ID := eStatus.UnknownToken, Severity
:= WagoTypesErrorBase.WagoTypes.eSeverity.error, text := ‘Receiving
unknown TOKEN from server’), STRUCT(ID := eStatus.SqlQueryFault,
Severity := WagoTypesErrorBase.WagoTypes.eSeverity.error, text :=
‘Response from SQL query could not be evaluated’), STRUCT(ID
:= eStatus.IdentifierExceeds250, Severity := WagoTypesError-
Base.WagoTypes.eSeverity.error, text := ‘Length of identifier in column “x”
exceed maximum of 250 bytes’), STRUCT(ID := eStatus.IdentifierToLarge,
Severity := WagoTypesErrorBase.WagoTypes.eSeverity.error, text
:= ‘Identifier for “fieldname” in column “x” exceed maximum’),
STRUCT(ID := eStatus.RowToLarge, Severity := WagoTypesError-
Base.WagoTypes.eSeverity.error, text := ‘Length of row data exceed
maximum ‘), STRUCT(ID := eStatus.RowReceivedToLarge, Severity :=
WagoTypesErrorBase.WagoTypes.eSeverity.warning, text := ‘Number of re-
ceived rows exceed maximum’), STRUCT(ID := eStatus.HostNotAssigned,
Severity := WagoTypesErrorBase.WagoTypes.eSeverity.error, text := ‘Input
sHost not assigned’), STRUCT(ID := eStatus.UserNotAssigned, Severity
:= WagoTypesErrorBase.WagoTypes.eSeverity.error, text := ‘Input sUser
not assigned’), STRUCT(ID := eStatus.ProtocolMissMatch, Severity :=
WagoTypesErrorBase.WagoTypes.eSeverity.error, text := ‘Library re-
quires protocol version 10 or above. Server supports only version x’),
STRUCT(ID := eStatus.InternalFunctionError, Severity := WagoTypesError-
Base.WagoTypes.eSeverity.error, text := ‘Function “FuMsSql_Scramble()”
returns with error’), STRUCT(ID := eStatus.ConvertToDottedFormatFailed,
Severity := WagoTypesErrorBase.WagoTypes.eSeverity.error, text :=
‘Could not convert servers IP address into dotted format’), STRUCT(ID
:= eStatus.ServerClosedConnection, Severity := WagoTypesError-
Base.WagoTypes.eSeverity.error, text := ‘Server closed connection’),
STRUCT(ID := eStatus.CreateSocketFailed, Severity := WagoType-
3.1. Status (GVL) 13
sErrorBase.WagoTypes.eSeverity.error, text := ‘Create socket failed’),
STRUCT(ID := eStatus.DNSRequestFailed, Severity := WagoType-
sErrorBase.WagoTypes.eSeverity.error, text := ‘DNS request failed’),
STRUCT(ID := eStatus.NoneBlockingFailed, Severity := WagoType-
WagoAppSQL_MsSQL, Release 1.6.2.1

Description: Status information

3.2 eStatus (ENUM)

InOut:

3.2. eStatus (ENUM) 14


WagoAppSQL_MsSQL, Release 1.6.2.1

Name Ini- Comment


tial
0 OK
OK
50 Not connected with data base
NotConnectedWith-
DataBase
51 Invalid response
InvalidResponse
52 Timeout
Timeout
53 Error message from server
ErrorMessage
54 Result set has more columns then defined in
ResultSetMoreCol-
´´MSSQL_MAX_COLUMN_COUNT´´
umn
55 Did not receive LOGINACK TOKEN
NoLoginAckToken
56 Receiving unknown TOKEN from server
UnknownToken
57 Response from SQL query could not be evaluated
SqlQueryFault
58 Length of identifier in column “x” exceed maximum of 250 bytes
IdentifierExceeds250
59 Identifier for “fieldname” in column “x” exceed maximum of
IdentifierToLarge
“MSSQL_MAX_IDENTIFIER_LENGTH”’;
60 Length of row data exceed maximum of “MSSQL_MAX_ROW_SIZE”
RowToLarge
61 Number of received rows exceed maximum of
RowReceivedTo-
“MSSQL_MAX_ROW_COUNT” - Some rows are ignored’
Large
62 Input sHost not assigned
HostNotAssigned
63 Input sUser not assigned
UserNotAssigned
64 Library requires protocol version 10 or above. Server support only ver-
ProtocolMissMatch
sion x
65 Function “MsSql_Scramble()” returns with error’
InternalFunction-
Error
66 Could not convert servers IP address into dotted format’
ConvertToDotted-
FormatFailed
67 Socket gracefully closed ->connection closed by server
ServerClosedCon-
nection
68 Create a socket failed
CreateSocketFailed
69 DNS request failed
DNSRequestFailed
70 Switching the socket to none blocking failed
NoneBlockingFailed
71 Receive buffer to small - increase
RxBufferToSmall
“MSSQL_RESPONSE_BUFFER_SIZE”
72 Transmit buffer to small - increase MSSQL_TX_BUFFER_SIZE
TxBufferToSmall
73 PARAM-ERROR: Requested “col” of currently unsupported type
ColumnTypUnsup-
ported
74 PARAM-ERROR: Requested “col” is not of type “STRING”
ColumnNotString
1000
Dummy

Description: Status information

3.2. eStatus (ENUM) 15


CHAPTER

FOUR

PARAMETERLIST (PARAMS)

InOut:

16
WagoAppSQL_MsSQL, Release 1.6.2.1

Scope Name Type Initial Comment


Constant DWORD 1000 Defines the re-
MSSQL_RESPONSE_BUFFER_SIZE ceive buffer size
for any SQL
response
DWORD 15
MSSQL_MAX_COLUMN_COUNT Defines the maximum number of co
this library
can process.

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

date ver- au- change


sion thor
31.01.20231.6.2.1 u0103719WAT34389: replace CDS3 Libs (Context:CmpErrors Interfaces -> CmpErrors2
Interfaces)
17.01.20231.6.2.0 u010663 Allow for 64-Bit system
24.09.20211.6.1.1 u010663 Allow strings greater than 255 ->internal improvement
08.01.20191.6.1.0 u015842 Properties: free placeholder added
10.09.20181.6.0.7 u010640 FuMsSql_GetString: Add support for TDS_DATA_BIGCHAR(16#AF)
10.09.20181.6.0.6 u010640 FbMsSql_Query: Bugfix - FB stalls in ‘wState=62’ on empty strings in DB
10.09.20181.6.0.5 u010640 FuMsSql_GetString: “sValue” now returns an empty string for “NULL-
VALUES” in DB instead of “Error-Messages”
03.01.20181.6.0.4 u010640 ResultsetHelpers: Add convert function to support 64bit float values
20.11.20171.6.0.2 u010640 FbMsSql_Execute: Bugfix increase length of ‘sHelp’
16.11.20171.6.0.1 u010640 FbMsSql_Query: Bugfix Stored procedure - Ignore DONE_INPROC Token
02.03.20161.6.0.0 u010663 Update to WagoSysErrorbase
19.01.20161.0.1.0 u010663 interface changed
12.01.20161.0.0.0 u010663 init

18
CHAPTER

SIX

LIBRARY REFERENCE

This is a dictionary of all referenced libraries and their name spaces.

CmpErrors2 Interfaces
Library Identification:
Name: CmpErrors2 Interfaces
Version: newest
Company: System
Namespace: CmpErrors

Library Properties:

• LinkAllContent: False • QualifiedOnly: False


• Optional: False • SystemLibrary: False

Standard
Library Identification:
Placeholder: Standard
Default Resolution: Standard, * (System)
Namespace: Standard

Library Properties:

• LinkAllContent: False • QualifiedOnly: False


• Optional: False • SystemLibrary: False

WagoSysBSDSocket
Library Identification:
Placeholder: WagoSysBSDSocket
Default Resolution: WagoSysBSDSocket, * (WAGO)
Namespace: WagoSysBSDSocket

Library Properties:

• LinkAllContent: False • QualifiedOnly: False


• Optional: False • SystemLibrary: False

19
WagoAppSQL_MsSQL, Release 1.6.2.1

WagoSysErrorBase
Library Identification:
Placeholder: WagoSysErrorBase
Default Resolution: WagoSysErrorBase, * (WAGO)
Namespace: WagoSysErrorBase

Library Properties:

• LinkAllContent: False • QualifiedOnly: False


• Optional: False • SystemLibrary: False

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:

• LinkAllContent: False • QualifiedOnly: False


• Optional: False • SystemLibrary: False

WagoTypesCommon
Library Identification:
Placeholder: WagoTypesCommon
Default Resolution: WagoTypesCommon, * (WAGO)
Namespace: WagoTypes

Library Properties:

• LinkAllContent: False • QualifiedOnly: True


• Optional: False • SystemLibrary: False

Library Parameter:
Parameter: MAX_STRING_LENGTH = 255
Parameter: MAX_WSTRING_LENGTH = 255

Based on WagoAppSQL_MsSQL.library, last modified 29.09.2023, 05:27:35. LibDoc 4.1.1.0

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

You might also like