开发者

Can a PL/pgSQL function contain a dynamic subquery?

I am writing a PL/pgSQL function. The function has input parameters which specify (indirectly), which tables to read filtering informa开发者_如何学Ction from.

The function embeds business logic which allows it to select data from different tables based on the input arguments. The function dynamically builds a subquery which returns filtering data which is then used to run the main query.

My questions are:

  1. Is it 'legal' to use a dynamic subquery in a PL/pgSQL function. I cant see why not - but this question is related to the next one.

  2. AFAIK, PL/pgSQL are cached or precompiled by the query engine. How does having a function that generates dynamic subqueries impact the work of the query engine?


"38.5.4. Executing Dynamic Commands"

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜