Thread: How to set decimal(7,2)?

How to set decimal(7,2)?

From
"sim"
Date:
How come when I try to set a variable as decimal(7,2), it
automatically complains that decimal(7,2) is not acceptable; however,
decimal(7,0) is okay? It changes to float4  by itself?

thanks.

Re: [GENERAL] How to set decimal(7,2)?

From
"Jose' Soares"
Date:
sim wrote:
>
> How come when I try to set a variable as decimal(7,2), it
> automatically complains that decimal(7,2) is not acceptable; however,
> decimal(7,0) is okay? It changes to float4  by itself?
>
> thanks.

From man pgbuiltin:

<DELETED>
       There  are  some data types defined by SQL/92 syntax which
       are mapped directly into native Postgres types. Note  that
       the "exact numerics" decimal and numeric have fully imple­
       mented syntax but currently (PostgreSQL v6.3) support only
       a limited range of the values allowed by SQL/92.

List of SQL/92 types
  POSTGRES Type  SQL/92 Type              Meaning
  char(n)        character(n)             fixed-length character string
  varchar(n)     character varying(n)     variable-length character
string
  float4/8       float(p)                 floating-point number with
precision p
  float8         double precision         double-precision
floating-point number
  float8         real                     double-precision
floating-point number
  int2           smallint                 signed two-byte integer
  int4           int                      signed 4-byte integer
  int4           integer                  signed 4-byte integer
  int4           decimal(p,s)             exact numeric for p <= 9, s =
0
  int4           numeric(p,s)             exact numeric for p == 9, s =
0
  timestamp      timestamp with time zone date/time
  timespan       interval                 general-use time span


                      Jose'