Re: [SQL] numeric conversions?

2000-11-20 Thread Jonathan Ellis

> is the type casting done automaticly? how? can i have an influence of
> the cast order? is there an easy way to doing the rounding?

bf2=# select 1 / 2 from dual;
 ?column?
--
0
(1 row)

bf2=# select 1::float / 2 from dual;
 ?column?
--
  0.5
(1 row)

bf2=# select (1::float / 2)::int from dual;
 ?column?
--
0
(1 row)

Also you have the functions round, floor, and ceil, which do what you would
expect.

-Jonathan




[SQL] String function page incorrect?

2000-11-30 Thread Jonathan Ellis

I'm trying to find the correct function that returns the location of a
substring within a string.  Looking at
http://www.postgresql.org/docs/user/x2731.htm, it gives the Function name as
"textpos" but in the Example column it uses "position".  But neither one
works!

bf2=# select position('high', 'ig');
ERROR:  parser: parse error at or near ","

bf2=# select textpos('high', 'ig');
ERROR:  Function 'textpos(unknown, unknown)' does not exist
 Unable to identify a function that satisfies the given argument types
 You may need to add explicit typecasts

bf2=# select textpos(text('high'), text('ig'));
ERROR:  Function 'textpos(text, text)' does not exist
 Unable to identify a function that satisfies the given argument types
 You may need to add explicit typecasts

???

-Jonathan