Re: Partition Help

From: Melvin Davidson <melvin6925(at)gmail(dot)com>
To: akshunj <rickjackson001(at)gmail(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Partition Help
Date: 2015-04-29 18:21:16
Message-ID: CANu8FiwxAwW5CUmQPXQNkSQ7X61OZ2M2ufWoxAtBNiYpbRsWMA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I think the problem is you need to specify NEW.invoice in all comparisons
(don't quote the 'column')and always, Always, ALWAYS end each statement
with a semicolon.

IE:
IF (NEW.invoice <= 'I-10000') THEN INSERT INTO myschema.mywork VALUES
(NEW.*)
ELSE IF (NEW.invoice >= 'I-10001' AND NEW.invoice <= 'I-20000')
THEN INSERT INTO myschema.mywork VALUES (NEW.*);

On Wed, Apr 29, 2015 at 11:05 AM, akshunj <rickjackson001(at)gmail(dot)com> wrote:

> Hi,
>
> I am trying to setup partitions and as a test, I was able to follow the
> example in the Postgres docs using the date as a condition.
>
> Now I am trying to partition on a column with the data type character
> varying. I want to partition based on an invoice ID consisting on letters
> and numbers like I-10, I-11. I create my function:
>
> IF ('invoice' <= 'I-10000') THEN INSERT INTO myschema.mywork VALUES (NEW.*)
> ELSE IF ('invoice' >= 'I-10001' AND <= 'I-20000') THEN INSERT INTO
> myschema.mywork VALUES (NEW.*)
>
> ELSE RAISE EXCEPTION...
>
> Is it possible to perform this type of operation with a mix of letters and
> numbers? So far any attempts to insert based on these conditions raises the
> exception.
>
> Thanks.
>
>
>
> --
> View this message in context:
> http://postgresql.nabble.com/Partition-Help-tp5847235.html
> Sent from the PostgreSQL - general mailing list archive at Nabble.com.
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

--
*Melvin Davidson*
I reserve the right to fantasize. Whether or not you
wish to share my fantasy is entirely up to you.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Joshua D. Drake 2015-04-29 18:57:51 Re: PostgreSQL HA config recommendations
Previous Message Melvin Davidson 2015-04-29 18:13:17 Re: