Re: [GENERAL] computed values in plpgsql

2009-09-29 Thread Sam Mason
On Tue, Sep 29, 2009 at 06:30:42PM +0200, Pavel Stehule wrote: > 2009/9/29 Sam Mason : > > I may have got that wrong somewhere else. > > I afraid so this technique is very buggy. You need unpacked serialised > record. Hum, I'm not sure what an "unpacked serialised record" is or why I'd need one.

Re: [GENERAL] computed values in plpgsql

2009-09-29 Thread Merlin Moncure
On Tue, Sep 29, 2009 at 10:49 AM, Reid Thompson wrote: > On Tue, 2009-09-29 at 07:54 -0400, Merlin Moncure wrote: > >> you are missing some quotes in there.  also, don't use 'values', use >> select.  see my example above: >> execute 'insert into foo_something select (''' || new::text || '''::foo).

Re: [GENERAL] computed values in plpgsql

2009-09-29 Thread Pavel Stehule
2009/9/29 Sam Mason : > On Tue, Sep 29, 2009 at 05:42:37PM +0200, Pavel Stehule wrote: >> you cannot use double quotes. It's not php. > > Normally yes, but *inside* literals you do indeed want double quotes. > > > I think the OP wants to be using quote_literal here.  I.e. instead of: > >  execute '

Re: [GENERAL] computed values in plpgsql

2009-09-29 Thread Sam Mason
On Tue, Sep 29, 2009 at 05:42:37PM +0200, Pavel Stehule wrote: > you cannot use double quotes. It's not php. Normally yes, but *inside* literals you do indeed want double quotes. I think the OP wants to be using quote_literal here. I.e. instead of: execute 'insert into foo_something select (

Re: [GENERAL] computed values in plpgsql

2009-09-29 Thread Pavel Stehule
2009/9/29 Reid Thompson : > On Tue, 2009-09-29 at 07:54 -0400, Merlin Moncure wrote: > >> you are missing some quotes in there.  also, don't use 'values', use >> select.  see my example above: >> execute 'insert into foo_something select (''' || new::text || '''::foo).*'; >> >> the actual query sho

Re: [GENERAL] computed values in plpgsql

2009-09-29 Thread Reid Thompson
On Tue, 2009-09-29 at 07:54 -0400, Merlin Moncure wrote: > you are missing some quotes in there. also, don't use 'values', use > select. see my example above: > execute 'insert into foo_something select (''' || new::text || '''::foo).*'; > > the actual query should look like: > insert into paym

Re: [GENERAL] computed values in plpgsql

2009-09-29 Thread Merlin Moncure
On Mon, Sep 28, 2009 at 4:29 PM, Reid Thompson wrote: > On Mon, 2009-09-28 at 11:05 -0400, Reid Thompson wrote: >> We have a set of tables that we're partitioning by year and month - > >> > > We can't seem to quite get it right... > This is our quick stub test. > > -- > -- Tables: > --

Re: [GENERAL] computed values in plpgsql

2009-09-28 Thread Reid Thompson
On Mon, 2009-09-28 at 11:05 -0400, Reid Thompson wrote: > We have a set of tables that we're partitioning by year and month - > We can't seem to quite get it right... This is our quick stub test. -- -- Tables: -- CREATE TABLE payments ( id serial, payment_name varcha

Re: [GENERAL] computed values in plpgsql

2009-09-28 Thread Martin Gainty
pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni. > Subject: [GENERAL] computed values in plpgsql > From: reid.thomp...@ateb.com > To:

Re: [GENERAL] computed values in plpgsql

2009-09-28 Thread Merlin Moncure
On Mon, Sep 28, 2009 at 1:29 PM, Reid Thompson wrote: > On Mon, 2009-09-28 at 12:42 -0400, Merlin Moncure wrote: > >> the best way to do this is very version dependent.  the basic trick is >> to use text cast to pass a composite type into the query sting. >> >> one way: >> execute 'insert into foo

Re: [GENERAL] computed values in plpgsql

2009-09-28 Thread Reid Thompson
On Mon, 2009-09-28 at 12:42 -0400, Merlin Moncure wrote: > the best way to do this is very version dependent. the basic trick is > to use text cast to pass a composite type into the query sting. > > one way: > execute 'insert into foo_something select (' || new::text || '::foo).*'; > > you can

Re: [GENERAL] computed values in plpgsql

2009-09-28 Thread Merlin Moncure
On Mon, Sep 28, 2009 at 11:05 AM, Reid Thompson wrote: > We have a set of tables that we're partitioning by year and month - > e.g. payments_parent, partitioned into payments_200901, payments200902, ... > and  inquiries_parent, partitioned into inquiries_200901, inquiries_200902, > ... > > Each t

[GENERAL] computed values in plpgsql

2009-09-28 Thread Reid Thompson
We have a set of tables that we're partitioning by year and month - e.g. payments_parent, partitioned into payments_200901, payments200902, ... and inquiries_parent, partitioned into inquiries_200901, inquiries_200902, ... Each table has a timestamp field import_ts that can be used to partition