Reputation: 35
This is my table: Table
I did this to populate it:
update AEROPORTO.RESERVA
set VALOR = random()*(5000-1500)+1500
where cod_reserva is not null
but random()
has double precision and i what my values like this:
and round()
doesn't use double precision.
I've tried to change the data type of the field Valor but didn't worked. Tried numeric, monetary and float.
I need to run a script that populates randomly this field with only 2 digits precision.
Upvotes: 1
Views: 72
Reputation: 4582
There are two round
functions, round(dp or numeric)
returns integer, and round(v numeric, s int)
that returns numeric
. Try the following:
update AEROPORTO.RESERVA
set VALOR = round((random()*(5000-1500)+1500)::numeric, 2)
where cod_reserva is not null
Upvotes: 1