Re: dynamic insert in plpgsql

From: Sam Mason <sam(at)samason(dot)me(dot)uk>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: dynamic insert in plpgsql
Date: 2010-01-08 14:58:58
Message-ID: 20100108145858.GD5407@samason.me.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Jan 08, 2010 at 02:55:53PM +0000, Grzegorz Jaaakiewicz wrote:
> Is there any nice way to do something like that in plpgsql:
>
> EXECUTE 'INSERT INTO '||partition_table_name||' VALUES'||(NEW.*)||'';
>
> It would probably work, but some values are NULL, and plpgsql
> interpreter just puts empty space there. So I get ('1',2,3,,,); Which
> obviously is confusing INSERT.

Yup, this thing is a bit fiddly. Try:

http://archives.postgresql.org/pgsql-general/2009-09/msg01176.php

--
Sam http://samason.me.uk/

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Grzegorz Jaśkiewicz 2010-01-08 15:03:58 Re: dynamic insert in plpgsql
Previous Message Grzegorz Jaśkiewicz 2010-01-08 14:55:53 dynamic insert in plpgsql