Stored procedure call
- Last UpdatedNov 18, 2022
- 1 minute read
- PI System
- Interfaces
The following query calls a stored procedure instead of directly executing a SELECT statement.
Stored procedure:
CREATE PROCEDURE StoredProcedure1 @StartTime DateTime, @EndTime DateTime AS
BEGIN
SET NOCOUNT ON
SELECT timestamp, value, status
FROM table15
WHERE timestamp BETWEEN @StartTime AND @EndTime ORDER BY timestamp ASC
END
Configure the target PI point with the following settings.
|
Point attribute |
Description |
Setting |
|---|---|---|
|
ExDesc |
Placeholders and options |
/SQL= "{CALL StoredProcedure1(?,?)};" P1=LST P2=ST |
|
Location2 |
First row/all rows |
1 (All rows are processed) |
|
Location3 |
Data distribution strategy |
0 (Single) |
|
Location4 |
Scan class |
1 |
|
Location5 |
Exception reporting |
1 (Exception reporting is turned off) |
|
InstrumentTag |
Name of the SQL file |
Example15.SQL |
|
PointType |
Data type of PI point |
Float32 |
In the RDBMS, create a table formatted as follows:
|
Column name |
Column data type |
|---|---|
|
SQL Server data type |
|
|
timestamp |
DateTime |
|
value |
Real |
|
status |
Smallint |