Not sure how to write the CTE form of this. This query gives an error that dave is missing a from clause entry. WITH o as ( SELECT getRecord(1, dave.field1) ) SELECT id, o.* FROM dave ; Regarding the INNER JOIN, actually it appears the opposite is true: SELECT id, generate_series(1, dave.field1) FROM Dave Works great if generate_series returns rows, but does not return any rows if generate_series does not return rows (i.e. if dave has a row with field1=null). So in fact, I need to figure out how to rewrite a LEFT
JOIN version of this query. From: David Johnston [mailto:polobo@xxxxxxxxx]
On Aug 15, 2012, at 15:55, David Greco <David_Greco@xxxxxxxxxxxxxxx> wrote:
I suggest putting your function calls within a CTE (common table _expression_: SQL command WITH) structure. I do not get why you think you need an "EXISTS" in the INNER JOIN situation. At worse you should make it a sub-query and add a IS NOT NULL condition on one of the function
result columns. There is no way to avoid evaluating once per record in dave but you should never have to evaluate more frequently than that. CTE and sub-selects are your friends. The original form is currently being developed but will not be available until at least 9.3 David J. |