Sample Programming
// ---------------------------------------------------------------------------------------------------------------------
// - Establish a DB Connection named MyDatabase1 and map a table with a variable.
// Start the sequence when the variable Trigger_Connect changes to TRUE.
IF ( (Trigger_Connect=TRUE)
AND (LastTrigger_Connect=FALSE)
AND (_DBC_Status.Run=TRUE) ) THEN
OperatingStart_Connect := TRUE;
Operating_Connect := TRUE;
END_IF;
LastTrigger_Connect:=Trigger_Connect;
// Sequence start processing
IF (OperatingStart_Connect=TRUE) THEN
// Initialize the instances of the applicable DB Connection Instructions.
DB_Connect_instance( Execute:=FALSE );
DB_CreateMapping_Select_instance(
Execute := FALSE,
MapVar := MapVar_Select,
SQLType := _DBC_SQLTYPE_SELECT
);
Stage := 1;
OperatingStart_Connect := FALSE;
END_IF;
// Establish the DB Connection named MyDatabese1.
// Map the variable MapVar_Select to the table Production of the DB Connection MyDB1 for the SELECT operation.
IF (Operating_Connect=TRUE) THEN
CASE Stage OF
1 : // Establish the DB Connection
DB_Connect_instance(
Execute := TRUE,
DBConnectionName := 'MyDatabase1',
DBConnection => MyDB1
);
IF (DB_Connect_instance.Done=TRUE) THEN
Stage := INT#2; // Normal end
END_IF;
IF (DB_Connect_instance.Error=TRUE) THEN
Stage := INT#99; // Error
END_IF;
2 : // Map the DB table with the variable