Notes on the Evaluation of QLingo Expressions
Any QLingo expression that does not depend on individual recipients is executed (evaluated) only once during production.
For example, if an ADOR retrieves data by executing an SQL query that does not have any parameters, and hence does not depend on the individual recipient, the query is executed a single time for the entire production run. This optimization prevents uProduce from needlessly repeating the same query and evaluating expressions when the values of ADORs for each individual recipient are calculated.
It is important that you understand how this optimization affects queries that use randomized values or are time-dependent. You will need to ensure that randomized values are recalculated for each recipient and not once for the entire production run.
Take, for example, the case where a campaign offers a random book name to each recipient:
SELECT TOP 1 books.name FROM books order by RAND(books.id)
The above query is not dependent on any recipient information whatsoever and will therefore not be evaluated separately for each recipient. As a result, all recipients will see the same book name in their document instances. You can easily work around this limitation by making your query dependent on the recipient ID:
SELECT TOP 1 books.name FROM books WHERE |->[ID] <> -1 order by rand (books.id)
The above query retrieves a random book name
for each recipient whose ID is not equal to
(-1). Assuming there are no recipients with an ID equal to (-1), this query
is executed for every recipient.