question on function definitions/casts - Mailing list pgsql-general

From Cindy
Subject question on function definitions/casts
Date
Msg-id 17659.1014239742@stephanus.tlg.uci.edu
Whole thread Raw
Responses Re: question on function definitions/casts  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
List pgsql-general
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

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: schema error upgrading from 7.1 to 7.2
Next
From: Stephan Szabo
Date:
Subject: Re: question on function definitions/casts