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

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.