DB_CreateMapping_Select_instance(
Execute := TRUE,
DBConnection := MyDB1,
TableName := 'Production',
MapVar := MapVar_Select,
SQLType := _DBC_SQLTYPE_SELECT
);
IF (DB_CreateMapping_Select_instance.Done=TRUE) THEN
Operating_Connect:=FALSE; // Normal end
END_IF;
IF (DB_CreateMapping_Select_instance.Error=TRUE) THEN
Stage := INT#99; // Error
END_IF;
99 :
// Execute the error handler.
// Program the error handler (FaultHandler_Connect) according to the device.
FaultHandler_Connect();
Operating_Connect := FALSE;
END_CASE;
END_IF;
// ---------------------------------------------------------------------------------------------------------------------
// - Retrieve the records for the specified lot number from the DB Connection MyDB1.
// Start the sequence when the variable Trigger_Select changes to TRUE.
IF ( (Trigger_Select=TRUE) AND (LastTrigger_Select=FALSE) ) THEN
OperatingStart_Select := TRUE;
Operating_Select := TRUE;
END_IF;
LastTrigger_Select := Trigger_Select;
// Sequence start processing
IF (OperatingStart_Select=TRUE) THEN
// Initialize the instance of the applicable DB Connection Instruction.
DB_Select_instance( Execute:=FALSE, MapVar:=MapVar_Select );
// Create the conditions for the Where clause ("LotNo" = XXXX).
WhereCond_Select := CONCAT( '"LotNo" = $'', UINT_TO_STRING( LotNo ), '$'' );
// Create the conditions for the Sort clause.
// Sort the production completion time in descending order.
SortCond_Select := '"FinishTime" DESC';
OperatingStart_Select := FALSE;
END_IF;