String function page incorrect?
String function page incorrect?
От:
"Jonathan Ellis" <jellis@advocast.com>
Дата:
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 existUnable to identify a function that satisfies the given argument typesYou may need to add explicit typecasts
bf2=# select textpos(text('high'), text('ig'));
ERROR: Function 'textpos(text, text)' does not existUnable to identify a function that satisfies the given argument typesYou may need to add explicit typecasts
???
-Jonathan
Re: String function page incorrect?
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
"Jonathan Ellis" writes:
> 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!
Yeah, that seems to be a few versions out of date :-(
The page should probably refer to "strpos", which is the true function
name:
play=> select strpos('high','ig');strpos
-------- 2
(1 row)
You can also use the SQL92 POSITION syntax:
play=> select position('ig' in 'high');strpos
-------- 2
(1 row)
regards, tom lane
Re: String function page incorrect?
От:
Roberto Mello <rmello@cc.usu.edu>
Дата:
Jonathan Ellis wrote:
>
> 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 ","
You need SELECT position('ig' in 'high');
lbn=# select position('ig' in 'high');strpos
-------- 2
(1 row)
-Roberto
--
Computer Science Utah State University
Space Dynamics Laboratory Web Developer
USU Free Software & GNU/Linux Club http://fslc.usu.edu
My home page - http://www.brasileiro.net/roberto