"David G. Johnston" <david.g.johns...@gmail.com> writes:
> On Sun, Mar 12, 2017 at 12:00 AM, vod vos <vod...@zoho.com> wrote:
>> The INSERT action still can be done. What I want is just how to limit the
>> length of the insert value, you can just type format like 59.22, only four
>> digits length.

> length(trunc(goose, 0)::text) + scale(goose)
> I suspect you might encounter some issues, namely around
> 123.456789::numeric(6,1) casting behavior and maybe
> 00059.12000::numeric(6,1) treatment of unimportant zeros.

Yeah.  I wonder if the OP wouldn't be better off thinking of his data as
strings rather than numbers.  The format requirement could be expressed
as a CHECK constraint, along the lines of length(goose) = 5 AND
goose ~ '^\d+\.\d+$' (or possibly \d* if zero digits on one side of
the decimal point is OK).  You could imagine storing as numeric and
having CHECK constraints that cast to string and make those tests,
but I fear trailing zeroes would break it.

                        regards, tom lane


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Reply via email to