简体   繁体   English

仅执行一次SQL函数

[英]Execute an SQL function only once

I have a formula field that gets its value from an expression field (which executes an SQL scalar function) but I want to make sure this expression field is executed only once (the SQL function is passed a row value which is the same for all the rows in the recordset) 我有一个公式字段,它从一个表达式字段(执行SQL标量函数)获取其值,但我想确保仅一次执行此表达式字段(该SQL函数传递的行值对于所有记录集中的行)

The way I see it, the formula field will end up calling the SQL function at every row being rendered in the report. 我的看法是,公式字段最终将在报表中呈现的每一行调用SQL函数。

How would one do that ? 那怎么办?

Assign the value from the SQL function to a global variable in the report header and then reuse the value from that variable instead of referencing the SQL. 将SQL函数中的值分配给报表标题中的全局变量,然后重用该变量中的值,而不是引用SQL。

//{@Assign Value} - formula placed in report header
numbervar ExampleVar := {%SQL Expression};

//{@Use Value} - value can now be used anywhere in the report
numbervar ExampleVar;
...do something with ExampleVar

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM