Re: User defined type without single quotes

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Rodrigo Barboza <rodrigombufrj(at)gmail(dot)com>
Cc: pgsql-docs(at)postgresql(dot)org
Subject: Re: User defined type without single quotes
Date: 2013-04-13 13:06:43
Message-ID: 1365858403.20086.7.camel@vanquo.pezone.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

On Thu, 2013-04-04 at 19:50 -0300, Rodrigo Barboza wrote:
> -- my_uint32 is my new type
> CREATE TABLE test (a my_uin32);
>
> If I try to run this insert, postgres complain about the type:
> INSERT INTO teste (a) VALUES (10);
>
> But this one works:
> NSERT INTO teste (a) VALUES ('10'::my_uint);
>
> Is there a way to avoid the single quotes?
>
A constant like 10 is initially assigned one of the integer types (the
exact rules are in the documentation). In order to be able to store
that into a column of a custom type, you need to define a cast between
the integer type and your type with at least assignment context.

In response to

Responses

Browse pgsql-docs by date

  From Date Subject
Next Message Rodrigo Barboza 2013-04-13 17:23:14 Re: User defined type without single quotes
Previous Message Gurjeet Singh 2013-04-11 08:07:41 Re: [DOCS] synchronize_seqscans' description is a bit misleading