PIUnitBatchSearch Method (PIModuleDB object)


Searches for PIUnitBatch's.



object.PIUnitBatchSearch varSearchStartTime, varSearchEndTime,bstrModuleNameMask, bstrBatchIDMask, bstrProductMask, bstrProcedureMask, bstrSubBatchMask, [AsynchStatus], [varUnitBatchUniqueID], [varModuleUniqueID]

The PIUnitBatchSearch method syntax has these parts:




An object expression that evaluates to a PIModuleDB object.


A VARIANT containing the search start time. The VARIANT may be a PITime, DATE, String, or numeric. Interpretation of DATE, strings and numerics is consistent with PITime's interpretation. NOTE:  The minimum start time passed should be PITime.UTCSeconds = 1. 


A VARIANT containing the search end time. The VARIANT may be a PITime, DATE, String, or numeric. Interpretation of DATE, strings and numerics is consistent with PITime's interpretation.


Wildcard string of a PIModule name to match. Defaults to “*”.


Wildcard string of BatchID to match. Defaults to “*”.


Wildcard string of Product to match. Defaults to “*”.


Wildcard string of ProcedureName to match. Defaults to “*”.


Wildcard string of SubBatch name to match. Defaults to “*”.


Optional asynchronous status object (PIAsyncStatus).


Optional unique id of PIUnitBatch. Used to find specific unit batch. Overrides all masks.


Optional unique id of PIModule. Used to find unit batches created on a specific module. Overrides the module name mask.



Returns a PIUnitBatchList of matching PIUnitBatch objects. PIUnitBatch objects have a primary index on time and PIModule; specifying small ranges of time and PIModule will result in fastest performance.


Any PIUnitBatch which has an EndTime on or after the search start and a start time on or before search end matches the search time criteria. Running PIUnitBatch's (PIUnitBatch's with no end time set) always match search times which include current time.


All five masks default to the wildcard character "*". Therefore just specifying search start and end returns all PIUnitBatch objects over that time range.


The pAsynchStatus argument is used for performing asynchronous calls. If this argument is passed, the method returns immediately with an empty list. This list is protected against access (an error of pseASYNCHMODEERR will be returned) until the call is complete.


The argument varUnitBatchUniqueID is used to retrieve a specific PIUnitBatch object. This argument, if set, overrides the search masks including the start and end time. The search start and end time are used as a hint for where to find the object, but it is possible that the matching object may have start and/or end times outside of the time range of the search.


If no PIUnitBatch's are found that match the search criteria, an empty list is returned.


Trappable Errors

In addition to generic errors (such as Out of Memory), the following errors may occur:




The parent underlying generic server object could not be retrieved.


Enabling Operational Intelligence