From: | Albe Laurenz <laurenz(dot)albe(at)wien(dot)gv(dot)at> |
---|---|
To: | "jagadishk *EXTERN*" <jagadishkantubugata(at)yahoo(dot)com>, "pgsql-novice(at)postgresql(dot)org" <pgsql-novice(at)postgresql(dot)org> |
Subject: | Re: ALTER TABLE some table ADD PARTITION partition_name VALUES less than (TO_DATE('variablex', 'DD/MM/YYYY')) ; |
Date: | 2014-04-23 12:25:18 |
Message-ID: | A737B7A37273E048B164557ADEF4A58B17CF3279@ntex2010i.host.magwien.gv.at |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
jagadishk wrote:
> I am writing a plsql code
> DECLARE
> sys_date character varying(500);
> variablex character varying(500);
> sys_date:='select to_char(now,''YYYYMMDD'')';
> execute immediate sys_date into variablex;
> dbms_output.put_line(variablex);
> begin
> ALTER TABLE some table ADD PARTITION partition_name VALUES less than
> (TO_DATE('variablex', 'DD/MM/YYYY')) ;
>
> I want to add a partition based on sysdate and each day a table would be
> created. So i am writing the code as above
>
> It throws an error
> ERROR: date format not recognized
> CONTEXT: SQL statement "ALTER TABLE some table ADD PARTITION partition_name
> VALUES less than (TO_DATE('variablex', 'DD/MM/YYYY'))"
> edb-spl function inline_code_block line 44 at SQL statement
Remove the single quotes around "variablex".
I believe that you need dynamic SQL to perform an ALTER TABLE.
Yours,
Laurenz Albe
From | Date | Subject | |
---|---|---|---|
Next Message | Thomas Kellerer | 2014-04-23 12:29:16 | Re: ALTER TABLE some table ADD PARTITION partition_name VALUES less than (TO_DATE('variablex', 'DD/MM/YYYY')) ; |
Previous Message | Gerald Cheves | 2014-04-23 11:55:12 | Re: PostgreSQL 9.1 not connecting |