position(text,text) function

position(text,text) function

Post by Karl Orbe » Tue, 24 Jul 2001 23:27:15



I'm having trouble using the position function, it's a simple built-in function.

It returns the index of a substring within a main string.

But, I just can't get it to work, it always gives this silly parser error.
I've tried it in a variety of ways with variables instead of constants casting
to text and using it in other contexts, (ie. in functions, not just in a
select).  What am I doing wrong?  Is this not the correct syntax for a two
argument function?

test=# select position('hello','el');
ERROR:  parser: parse error at or near ","

Karl Orbell.

 
 
 

position(text,text) function

Post by Jeff Eckerma » Wed, 25 Jul 2001 03:45:22


You are confusing the syntax of two similar functions:
position ('substring' in 'string')
strpos ('string', 'substring').
I have a feeling that "position" actually calls "strpos", but I am guessing
on that.

> -----Original Message-----

> Sent:      Monday, July 23, 2001 9:27 AM

> Subject:   position(text,text) function

> I'm having trouble using the position function, it's a simple built-in
> function.

> It returns the index of a substring within a main string.

> But, I just can't get it to work, it always gives this silly parser error.
> I've tried it in a variety of ways with variables instead of constants
> casting
> to text and using it in other contexts, (ie. in functions, not just in a
> select).  What am I doing wrong?  Is this not the correct syntax for a two

> argument function?

> test=# select position('hello','el');
> ERROR:  parser: parse error at or near ","

> Karl Orbell.

> ---------------------------(end of broadcast)---------------------------


---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

 
 
 

position(text,text) function

Post by Dorin Grunbe » Wed, 25 Jul 2001 04:24:48


--=====================_16626521==_.ALT
Content-Type: text/plain; charset="us-ascii"; format=flowed

The correct way would be:

select position('el' in 'Hello');

Dorin


>I'm having trouble using the position function, it's a simple built-in
>function.

>It returns the index of a substring within a main string.

>But, I just can't get it to work, it always gives this silly parser error.
>I've tried it in a variety of ways with variables instead of constants
>casting
>to text and using it in other contexts, (ie. in functions, not just in a
>select).  What am I doing wrong?  Is this not the correct syntax for a two
>argument function?

>test=# select position('hello','el');
>ERROR:  parser: parse error at or near ","

>Karl Orbell.

>---------------------------(end of broadcast)---------------------------


--=====================_16626521==_.ALT
Content-Type: text/html; charset="us-ascii"

<html>
<font size=3>The correct way would be:<br>
<br>
select position('el' in 'Hello');<br>
<br>
Dorin<br>
<br>

<blockquote type=cite cite>I'm having trouble using the position
function, it's a simple built-in function.<br>
<br>
It returns the index of a substring within a main string.<br>
<br>
But, I just can't get it to work, it always gives this silly parser
error.<br>
I've tried it in a variety of ways with variables instead of constants
casting <br>
to text and using it in other contexts, (ie. in functions, not just in a
<br>
select).&nbsp; What am I doing wrong?&nbsp; Is this not the correct
syntax for a two <br>
argument function?<br>
<br>
test=# select position('hello','el');<br>
ERROR:&nbsp; parser: parse error at or near &quot;,&quot;<br>
<br>
<br>
Karl Orbell.<br>
<br>
<br>
---------------------------(end of
broadcast)---------------------------<br>
TIP 1: subscribe and unsubscribe commands go to

</html>

--=====================_16626521==_.ALT--

 
 
 

position(text,text) function

Post by Josh Berku » Wed, 25 Jul 2001 04:36:14


Jeff, Karl,

Actually, he's confusing 3 functions.  See postgresql.org --> user
lounge --> interactive docs --> functions and operators --> string
functions.

-Josh

> You are confusing the syntax of two similar functions:
> position ('substring' in 'string')
> strpos ('string', 'substring').
> I have a feeling that "position" actually calls "strpos", but I am
> guessing
> on that.

> > -----Original Message-----

> > Sent: Monday, July 23, 2001 9:27 AM

> > Subject: position(text,text) function

> > I'm having trouble using the position function, it's a simple
> built-in
> > function.

> > It returns the index of a substring within a main string.

> > But, I just can't get it to work, it always gives this silly parser
> error.
> > I've tried it in a variety of ways with variables instead of
> constants
> > casting
> > to text and using it in other contexts, (ie. in functions, not just
> in a
> > select).  What am I doing wrong?  Is this not the correct syntax
> for a two

> > argument function?

> > test=# select position('hello','el');
> > ERROR:  parser: parse error at or near ","

> > Karl Orbell.

> > ---------------------------(end of
> broadcast)---------------------------
> > TIP 1: subscribe and unsubscribe commands go to

> ---------------------------(end of
> broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster

______AGLIO DATABASE SOLUTIONS___________________________
                                       Josh Berkus

   and data management solutions       (415) 565-7293
  for law firms, small businesses        fax 621-2533
    and non-profit organizations.      San Francisco

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate

message can get through to the mailing list cleanly

 
 
 

position(text,text) function

Post by omid omoom » Wed, 25 Jul 2001 04:52:56


position ( 'el' in 'hello') ;



>Subject: [SQL] position(text,text) function
>Date: Mon, 23 Jul 2001 14:27:15 +0000 (UTC)

>I'm having trouble using the position function, it's a simple built-in
>function.

>It returns the index of a substring within a main string.

>But, I just can't get it to work, it always gives this silly parser error.
>I've tried it in a variety of ways with variables instead of constants
>casting
>to text and using it in other contexts, (ie. in functions, not just in a
>select).  What am I doing wrong?  Is this not the correct syntax for a two
>argument function?

>test=# select position('hello','el');
>ERROR:  parser: parse error at or near ","

>Karl Orbell.

>---------------------------(end of broadcast)---------------------------


_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command

 
 
 

position(text,text) function

Post by Karl Orbe » Wed, 25 Jul 2001 22:53:57


Many thanks for all of the assistance on this question.

I can't say I've ever seen the "a in b" syntax in postgres, but
you live and learn. ;-)

Thanks again.

Karl.


> I'm having trouble using the position function, it's a simple built-in function.

> It returns the index of a substring within a main string.

> But, I just can't get it to work, it always gives this silly parser error.
> I've tried it in a variety of ways with variables instead of constants casting
> to text and using it in other contexts, (ie. in functions, not just in a
> select).  What am I doing wrong?  Is this not the correct syntax for a two
> argument function?

> test=# select position('hello','el');
> ERROR:  parser: parse error at or near ","

> Karl Orbell.

 
 
 

1. create a postscript file where the text is text

how do i create a ps file where the text is text and not rastorized.
Ihave engineering drawings that I am creating a ps file by printing to
a postscript printer using print to file, then the ps file is
converted to a pdf file using ghostscript...and the file looks
great...the only issue is that when i select text - it does not find
any..my assumption is that the process of converting to the ps file
did not create true text...it rastorized it.

thanks in advance.

2. RAS ok with WIN98 - Not with Win2k client?

3. Quark - color text default overprint black text

4. Looking for E1 telecom chassis

5. Need to get text out of quark and into word doc or text file

6. Use of British Answering Machines in the US

7. Quark text shadowed text - colour spec'ing

8. Q: Break signal from os9, using Greenspring IP422octal

9. centering macro text in a title statement where the text leng th i s variable

10. centering macro text in a title statement where the text length i s variable

11. FW: centering macro text in a title statement where the text leng th i s variable

12. comparing a tab delimited text file with regular text file

13. Comparing a tab delimited text file with regular text file