Please don't top-post on these lists. On Sun, Mar 12, 2017 at 12:00 AM, vod vos <vod...@zoho.com> wrote:
> Maybe CHECK (goose >= 100 AND goose <= -100) works better, But if : > > INSERT INTO test VALUES (1, 59.2); > INSERT INTO test VALUES (1, 59.24); > INSERT INTO test VALUES (1, 59.26); > INSERT INTO test VALUES (1, 59.2678); > > 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. I haven't tested any of that. The above will get you a single length value for a given input. David J.