Обсуждение: question on function definitions/casts
ANyway, I have another question for you guys.
create function get_citation (int2, int2, int4)
returns SETOF varchar AS
'select citation from citations where aid=$1 and wid=$2 and byteloc=$3'
LANGUAGE 'SQL'
At one point I retrieved this function from my psql db (I've taken over
from someone else) and I'm now in a position where I need to enter it again.
I got it using pg_dump -s (on the kind suggestion of Tom when I asked back
then).
However, when I enter it now, it just doesn't seem to like it.
I get:
Text=# create function get_citation (int2, int2, int4)
Text-# returns SETOF varchar AS
Text-# 'select citation from citations where aid=$1 and wid=$2 and byteloc=$3'
Text-# LANGUAGE 'SQL';
ERROR: Unable to identify an operator '=$' for types 'int2' and 'int4'
You will have to retype this query using an explicit cast
Text=#
I'm guessing this is a difference from an upgrade to psql?
I'm using:
[1:08pm] stephanus ~> psql -V
psql (PostgreSQL) 7.1.3
would this be something like:
cast(aid as int2)=$1
or
(int2 aid)=$1
I've read through the stuff in
http://www.ca.postgresql.org/users-lounge/docs/7.2/postgres/typeconv-oper.html
but I'm still confused.
Thanks,
--Cindy
On Wed, 20 Feb 2002, Cindy wrote: > I get: > > Text=# create function get_citation (int2, int2, int4) > Text-# returns SETOF varchar AS > Text-# 'select citation from citations where aid=$1 and wid=$2 and byteloc=$3' > Text-# LANGUAGE 'SQL'; > ERROR: Unable to identify an operator '=$' for types 'int2' and 'int4' > You will have to retype this query using an explicit cast > Text=# Hmm, try putting a space between the = and the $<n>
Stephan Szabo writes: >On Wed, 20 Feb 2002, Cindy wrote: > >> I get: >> >> Text=# create function get_citation (int2, int2, int4) >> Text-# returns SETOF varchar AS >> Text-# 'select citation from citations where aid=$1 and wid=$2 and byteloc= >$3' >> Text-# LANGUAGE 'SQL'; >> ERROR: Unable to identify an operator '=$' for types 'int2' and 'int4' >> You will have to retype this query using an explicit cast >> Text=# > >Hmm, try putting a space between the = and the $<n> > Yep. The irony of this, of course, is that the first problem I solved with this saved definition is that SETOF was originally SET OF. So...subtract spaces, add spaces...*sigh* Thanks! -- Cindy ctmoore@uci.edu