Re: Some help with functions-syntax - Mailing list pgsql-sql

From John DeSoi
Subject Re: Some help with functions-syntax
Date
Msg-id 603CB0E8-EFBD-4762-BC45-AFAD248E484B@pgedit.com
Whole thread Raw
In response to Re: Some help with functions-syntax  ("Jan Meyland Andersen" <jma@agile.dk>)
List pgsql-sql
On Jan 18, 2007, at 2:38 AM, Jan Meyland Andersen wrote:

> But the problem here is that the where-clause depends on the  
> relkind. That
> is why I'm trying to solve the problem this way.

I think that clause can be written as a subselect and added to the  
expression. Or just make that a separate function and AND the  
function call with your query expression.


>
> How do I then write EXECUTE queries on multiple lines, if I go with  
> this
> solution?

You can make it a big multi-line string. Or you can build the string,  
something like:

declare
_sql

begin

_sql := _sql + 'select ...'
_sql := _sql + ' where ...'


But using the form without execute is much better. PostgreSQL will  
only have to plan the query the first time it is called. Using  
EXECUTE is much less efficient.



John DeSoi, Ph.D.
http://pgedit.com/
Power Tools for PostgreSQL



pgsql-sql by date:

Previous
From: "Jan Meyland Andersen"
Date:
Subject: Re: Some help with functions-syntax
Next
From: "Barbara Cosentino"
Date:
Subject: Help ... Unexpected results when using limit/offset with select statement..DB corruption?