Dynamically update/assign @parameter in query

edited February 2021 in Open Query Builder

Hi,

I've got a query which passes correctly in mysql.

Problematic in FastReport query window is:

...

@SecI := t.TimestampCol AS ChangeTime

...

This line is not a static parameter assignment but its being used as a dynamically updated variable for:

IF(@SecI = 0, 0, TIMESTAMPDIFF(SECOND, @SecI, t.TimestampCol)) AS SecI

@SecI is initialized in the query as: SELECT @SecI := 0


Both cases of using ":=" (colon-equal-sign- /assignment-) operator together with @ (at-operator) operator result in an error.

On "define parameter" page within FastReport query wizard @SecI is defined as double with default value zero.

I could probably go with:

1) "Expression" an create my "@SecI := t..." dataset elsewhere and reference it my original query

2) Rewrite the query to calculate SecI differently

But: I am interested in this specific self-consistent implementation.

Do you have any suggestions how to syntactically write this in a FastReport compatible way using the (":=") assignment operator?


Kind regards

JJ

Leave a Comment