Serg 基本上是正确的。 单独 因此它必须是有效的sql语句()。
但是要在这里正确引用它,您的示例应该类似于(实际上,您应该 ):
eval(
'select '||c.price_expression||' from product where id=:pid',
'{"{cost}",:pid}',
array[ p.cost, p.id ]
) as cust_cost
与 Serg 的建议相比,这应该更加直接,健壮和模块化。
如何修复postgres-utils eval()错误:缺少表“ oo”的FROM子句条目?
Serg 基本上是正确的。 单独 因此它必须是有效的sql语句()。
但是要在这里正确引用它,您的示例应该类似于(实际上,您应该 ):
eval(
'select '||c.price_expression||' from product where id=:pid',
'{"{cost}",:pid}',
array[ p.cost, p.id ]
) as cust_cost
与 Serg 的建议相比,这应该更加直接,健壮和模块化。