pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bill MacArthur <webmaster@dhs-club.com>
To: pgsql-bugs@postgresql.org
Subject: Re: TYPE of TEMP table does not seem to get set
Date: Mon, 16 Apr 2012 16:29:00 -0400
Message-ID: <4F8C810C.6000408@dhs-club.com> (raw)
In-Reply-To: <4379.1334607089@sss.pgh.pa.us>
References: <4F8C771A.2040509@dhs-club.com>
	<4379.1334607089@sss.pgh.pa.us>

On 4/16/2012 4:11 PM, Tom Lane wrote:
> Bill MacArthur<webmaster@dhs-club.com>  writes:
>> I have a view "configurations.tp_transactions" which is a blend of many tables using INNER and LEFT JOINs. I want to populate a temp table from which I can obtain the data and programmatically write queries to operate on that data using certain PLPGSQL functions in a uniform fashion. I have several functions which all expect a single argument of the type "configurations.tp_transactions".
>
> I think you would need to create the temp table as a child of the main
> table for this to work.  As you're doing it, the rowtype of the temp
> table is independent of the main (and the fact that they happen to have
> the same columns is NOT good enough to make it acceptable to a function
> declared to take the main table's rowtype).
>
> 			regards, tom lane
>

I have tried this but no go:
network=# create temp table chl() inherits (configurations.tp_transactions);
ERROR:  inherited relation "tp_transactions" is not a table

This does not work either:
network=> CREATE TEMP TABLE myt OF configurations.tp_transactions;
CREATE TABLE
network=> \d myt
               Table "pg_temp_11.myt"
     Column     |         Type         | Modifiers
---------------+----------------------+-----------
  id            | integer              |
<snip>
  amount        | numeric              |
  pp_value      | numeric              |
Typed table of type: configurations.tp_transactions

network=> insert into myt select * from configurations.tp_transactions where trans_id=920787;
INSERT 0 1

network=> select configurations.myself(myt.*) from myt;
ERROR:  function configurations.myself(myt) does not exist
LINE 1: select configurations.myself(myt.*) from myt;
                ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.

network=> select configurations.myself(myt.*) from configurations.tp_transactions myt where trans_id=920787;
  myself
--------
      12
(1 row)



view thread (4+ messages)  latest in thread

Message-ID: <4F8C810C.6000408@dhs-club.com>
Permalink:  ../4F8C810C.6000408@dhs-club.com/
Also on:    postgresql.org/message-id/4F8C810C.6000408@dhs-club.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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: webmaster@dhs-club.com
  Subject: Re: TYPE of TEMP table does not seem to get set
  In-Reply-To: <4F8C810C.6000408@dhs-club.com>
  References: <4F8C771A.2040509@dhs-club.com> <4379.1334607089@sss.pgh.pa.us> <4F8C810C.6000408@dhs-club.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