Thread: Data Type precision
CREATE TABLE TR (f1 FLOAT4, f2 INT4, f3 INT4) ; UPDATE TR SET f1=f2/f3::FLOAT4 ; f1 -> xxxxxx,xxxxxx - but I want f1 -> xxxxxx,xx. (6,6) (6,2) anybody can help me ? Thanks. Jerome.
/* ----------------* Karel Zak * zakkr@zf.jcu.cz * http://home.zf.jcu.cz/~zakkr/* C, PostgreSQL, PHP, WWW,http://docs.linux.cz* ----------------*/ On Tue, 26 Sep 2000, Jerome Raupach wrote: > CREATE TABLE TR (f1 FLOAT4, f2 INT4, f3 INT4) ; > > UPDATE TR SET f1=f2/f3::FLOAT4 ; > > f1 -> xxxxxx,xxxxxx - but I want f1 -> xxxxxx,xx. > (6,6) (6,2) See formatting functions in docs: test=# SELECT TO_CHAR( 123456.123456, '999999.99')::float8;?column? -----------123456.12 (1 row) Note, really float4 with 8 places (6,2)? test=# select '123456.12'::float4;?column? ---------- 123456 (1 row) test=# select '1234.12'::float4;?column? ---------- 1234.12 (1 row) test=# select '123456.12'::float8;?column? -----------123456.12 (1 row) Karel
Hi, there, You can use function: urldb=# select round(234.356534,2);round --------234.36 (1 row) Jerome Raupach wrote: > CREATE TABLE TR (f1 FLOAT4, f2 INT4, f3 INT4) ; > > UPDATE TR SET f1=f2/f3::FLOAT4 ; > > f1 -> xxxxxx,xxxxxx - but I want f1 -> xxxxxx,xx. > (6,6) (6,2) > > anybody can help me ? > Thanks. Jerome. -- Jie LIANG Internet Products Inc. 10350 Science Center Drive Suite 100, San Diego, CA 92121 Office:(858)320-4873 jliang@ipinc.com www.ipinc.com
Folks, Here's three unrelated questions which have been bothering me: 1. What TYPE does one use in a Create Function statement to return a full dataset? (Create Function XXX AS VIEW? Create Function XXX AS TABLE?) 2. The Curval(), Setval() and Nextval() functions allow one to easily manage SERIAL values for multi-table updates. Can someone give me an easy way, within a function, to grab the OID returned by the INSERT statement? 3. I seem to remember reading somewhere some bitwise operators for PGSQL. But I can't find them in the documentation now. Was I mistaken? Do we just use modulo instead? Thanks for any advice! -Josh Berkus