From: | Erik Wienhold <ewie(at)ewie(dot)name> |
---|---|
To: | sud <suds1434(at)gmail(dot)com> |
Cc: | Greg Sabino Mullane <htamfids(at)gmail(dot)com>, pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Timestamp conversion Error in dynamic sql script |
Date: | 2024-04-02 20:57:35 |
Message-ID: | 6oywkrrg5bzvnmorg7l3kdvzc2ipejm2xx3o5qaam57chuacic@iu4pe64gjqoj |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 2024-04-02 22:08 +0200, sud wrote:
> On Tue, Apr 2, 2024 at 7:46 PM Greg Sabino Mullane <htamfids(at)gmail(dot)com>
> wrote:
>
> Now this block seems to be failing near the "LIKE" operator. Isn't it
> allowed to add the check constraints along with the CREATE TABLE statement?
>
> [...]
>
> EXECUTE format('
> CREATE TABLE parent_table_%s (
> CHECK (partition_key >= ''%s'' AND partition_key < ''%s'' )
> * ) LIKE (parent_table including all);',*
> TO_CHAR(start_date + make_interval(days=>i),'YYYY_MM_DD'),
> (start_date + make_interval(days=>i))::timestamptz ,
> (start_date + make_interval(days=>i))::timestamptz
> );
>
> [...]
>
> *SQL Error [42601]: ERROR: syntax error at or near "LIKE"Where: PL/pgSQL
> function inline_code_block line 8 at EXECUTE*
> *Error position: *
The LIKE clause goes inside the parenthesis along with the column and
constraint definitions, i.e.:
CREATE TABLE parent_table_yyyy_mm_dd (
LIKE parent_table,
CHECK (...)
);
--
Erik
From | Date | Subject | |
---|---|---|---|
Next Message | David Gauthier | 2024-04-02 23:53:46 | What linux version to install ? |
Previous Message | sud | 2024-04-02 20:08:39 | Re: Timestamp conversion Error in dynamic sql script |