> For the complete documentation index, see [llms.txt](https://docs.videc.de/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.videc.de/june5-3.6/datenquellenunterstuetzung-und-einbindung/honeywell-experion-batch-heb/sql-befehl-ereignisse.md).

# SQL-Befehl Ereignisse

Der Befehl zur Ermittlung der Ereignisse von Unit-Batches aus HEB Datenquellen ist eine SQL SELECT-Anweisung, die nach der folgenden Syntax aufgebaut ist:

{% code lineNumbers="true" %}

```sql
SELECT
   [PROCEDURAL_ELEMENT_EXECUTION].[STARTTIME] AS [StartTime],
   [PROCEDURAL_ELEMENT_EXECUTION].[ENDTIME] AS [EndTime],
   [PROCEDURAL_ELEMENT_EXECUTION].[USERPROCEDUREID] AS [LotNumber],
   [EQUIPMENT].[FULLNAME] AS [Namespace],
   [EQUIPMENT].[NAME] AS [ItemName],
   [EQUIPMENT].[EQUIPMENTLEVELNAME] AS [EquipmentName],
   [PROCEDURAL_ELEMENT].[FULLNAME] AS [ProceduralPath],
   [PROCEDURAL_ELEMENT].[PROCEDURELEVELNAME] AS [ProceduralLevelName],
   [PROCEDURAL_ELEMENT].[PHASENAME] AS [ProceduralPhaseName],
   [PROCEDURAL_ELEMENT].[NAME] AS [ProceduralName],
   [PE_EVENTS].[CATEGORYNAME] AS [EventCategoryName],
   [PE_EVENTS].[CONDITIONNAME] AS [EventConditionName],
   [PE_EVENTS].[SUBCONDITIONNAME] AS [EventSubcondition],
   [PE_EVENTS].[SOURCE] AS [EventSource],
   [PE_EVENTS].[PRIORITY] AS [EventPriority],
   [PE_EVENTS].[VALUE] AS [EventValue],
   [PE_EVENTS].[TIMESTAMP] AS [EventTime],
   [EQ_PE_XREF].[AREANAME] AS [EventAreaName],
   [PE_EVENTS].[DESCRIPTION] AS [EventDescription],
   [PROCEDURAL_ELEMENT_EXECUTION].[PROCEDUREEXECUTIONID] AS [ProcExecutionID],
   [PROCEDURAL_ELEMENT_EXECUTION].[PARENTID] AS [ProcElExecID]
FROM
   [ProcedureAnalyst].[pa].[TPB_VW_PROC_EXEC] [PROCEDURAL_ELEMENT_EXECUTION],
   [ProcedureAnalyst].[pa].[TPB_VW_PROC] [PROCEDURAL_ELEMENT],
   [ProcedureAnalyst].[pa].[TPB_VW_EQ] [EQUIPMENT],
   [ProcedureAnalyst].[pa].[TPB_VW_EQ_PE_XREF] [EQ_PE_XREF],
   [ProcedureAnalyst].[pa].[TPB_VW_PE_EVENTS] [PE_EVENTS]
WHERE
      [EQ_PE_XREF].[EQUIPMENTID]=[PROCEDURAL_ELEMENT_EXECUTION].[EQUIPMENTID] AND
      [PE_EVENTS].[AREANAME]=[EQ_PE_XREF].[AREANAME] AND
      [PE_EVENTS].[TIMESTAMP]>=[PROCEDURAL_ELEMENT_EXECUTION].[STARTTIME] AND
      [PE_EVENTS].[TIMESTAMP]<=[PROCEDURAL_ELEMENT_EXECUTION].[ENDTIME] AND
      [PROCEDURAL_ELEMENT_EXECUTION].[PROCEDUREID]=[PROCEDURAL_ELEMENT].[PROCEDUREID] AND
      [PROCEDURAL_ELEMENT_EXECUTION].[EQUIPMENTID]=[EQUIPMENT].[EQUIPMENTID]
```

{% endcode %}

Der SQL-Befehl zur Ermittlung der Ereignisse enthält Aliasnamen. Diese Aliasnamen stehen in eckigen Klammern rechts neben dem Wort "AS".

{% hint style="info" %}

* Ereignisse, die zu einem Unit-Batch zugeordnet sind, können nur erfolgreich ermittelt werden, wenn beide Bedingungen erfüllt sind:
  * Der Namensraum des Unit-Batches ist im Namesraum des Ereignisses enthalten
  * Der Chargennummer des Unit-Batches ist in der Item-Id des Ereignisses enthalten
* Die Aliasnamen im Befehl darf anpasst werden.
  {% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.videc.de/june5-3.6/datenquellenunterstuetzung-und-einbindung/honeywell-experion-batch-heb/sql-befehl-ereignisse.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
