...
IF ( :new.h - :lasth ) => 1800 THEN EXIT;

to

SELECT h FROM dbo.orx WHERE avgt = 1;
...
IF ( h - lasth ) >= 1800 THEN RETURN;


Explanation :
1. NEW/OLD is only allowed in UPDATE triggers.
2. Parameters are needed in SQL statements only. In IF statements no parameters must be used.
3. leave the trigger via the RETURN statement.
I didn't understand what you want to do if more than
1800 seconds have passed. If you want the triggering
insert statement to fail, you must set an error. In this
case please substitute the RETURN statement by a STOP statement :
IF ( h - lasth ) >= 1800 STOP (-31000, 'more than 1800 seconds');
Thank you for your response.

Here is the entire story. I collect values at 300s (5 mins). I want to graph those values for daily, weekly, monthly, yearly interval. I want to keep this statistics into an SQL table. When I need to draw a graph I don't want to select 100K values for the whole year, so I must follow some precomputed data: averages. I also don't want to compute this averages in application at insert, but to use the sapdb
trigger capabilities. Every entry in the table has an average column. This way, the average values will be stored in the same table with the normal (current) one. When a new value is inserted at 300 seconds the mkavg trigger will rise. Trigger that should do something like:

select h1 from table where avg is 1 (the avg for 1800 seconds)
if (h - h1) => 1800 then
- sum all the values since lasth and divide them by there count (normal average).
- insert tis average.
do the same thing for the 7200 and 86400 values.


(The example trigger is my first step in achieving this goal. There are also many steps, but can't find the suitable informations).

Can you help me with the entire problem ?


Thank you again.


dim





_______________________________________________
sapdb.general mailing list
[EMAIL PROTECTED]
http://listserv.sap.com/mailman/listinfo/sapdb.general

Reply via email to