pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stephan Szabo <sszabo@megazone.bigpanda.com>
To: Mario Splivalo <mario.splivalo@mobart.hr>
Cc: pgsql-sql@postgresql.org
Subject: Re: Using Temporary Tables in postgres functions
Date: Thu, 25 Jan 2007 08:03:51 -0800 (PST)
Message-ID: <20070125080212.M1153@megazone.bigpanda.com> (raw)
In-Reply-To: <1169735954.31872.38.camel@localhost.localdomain>
References: <1169735954.31872.38.camel@localhost.localdomain>

On Thu, 25 Jan 2007, Mario Splivalo wrote:

> When I try to use TEMPORARY TABLE within postgres functions (using 'sql'
> as a function language), I can't because postgres can't find that
> temporary table. Consider this example:
>
> CREATE FUNCTION func1() RETURNS SETOF v_messages_full AS $BODY$
> CREATE TEMPORARY TABLE tmpTbl
> AS
> SELECT
> 	message_id
> FROM
> 	cached_messages
> WHERE
> 	billing_status = 2;
>
>
> UPDATE cached_messages SET billing_status = 1 WHERE message_id IN
> (SELECT message_id FROM tmpTbl);
>
> SELECT
> 	*
> FROM
> 	v_messages_full
> WHERE
> 	message_id IN (SELECT message_id FROM tmpTbl);
> $BODY$ LANGUAGE 'sql' VOLATILE SECURITY DEFINER;

It seems like the sql function checker is unhappy with the above. Does it
actually work if you turn off the check_function_bodies configuration
variable, create the function and then call it?



view thread (8+ messages)  latest in thread

Message-ID: <20070125080212.M1153@megazone.bigpanda.com>
Permalink:  ../20070125080212.M1153@megazone.bigpanda.com/
Also on:    postgresql.org/message-id/20070125080212.M1153@megazone.bigpanda.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: sszabo@megazone.bigpanda.com, mario.splivalo@mobart.hr
  Subject: Re: Using Temporary Tables in postgres functions
  In-Reply-To: <20070125080212.M1153@megazone.bigpanda.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox