From: Jackson, DeJuan <djackson@cpsgroup.com>
To: Konstantinos Vassiliadis <vassilik@p22.cs.man.ac.uk>
To: pgsql-sql@postgreSQL.org
Subject: RE: [SQL] Typecasting in SQL functions
Date: Wed, 15 Jul 1998 12:43:46 -0500
Message-ID: <F10BB1FAF801D111829B0060971D839F33315F@cpsmail> (raw)
You might want to add a space before the '$'. '=$' is a valid Postgres
operator so it thinks of it as one token.
-DEJ
> -----Original Message-----
> From: Konstantinos Vassiliadis [SMTP:vassilik@p22.cs.man.ac.uk]
> Sent: Tuesday, July 14, 1998 7:34 AM
> To: pgsql-sql@postgreSQL.org
> Subject: [SQL] Typecasting in SQL functions
>
> Hi,
> I have the following
>
> create table reference
> (author text,
> journal text);
>
> create table subref
> (ref reference);
>
> I want to insert a tuple into relation 'subref'. I spotted in the
> mailing
> list that Nicolas Caillaud created a function to insert values to his
> relation 'book' so I thought I tried the same
>
> create function add_ref(text,text) returns reference
> as 'select * from reference
> where author=$1 and journal=$2'
> language 'sql';
>
> I get the following
> ERROR: There is no operator '=$' for types 'text' and 'int4'
> You will either have to retype this query using an explicit
> cast,
> or you will have to define the operator using CREATE OPERATOR
>
> Obviously it confuses author=$1...
> I have looked at the documenation (Ch 4. 'Extending SQL Functions'
> PostgreSQL Programmer's Guide) where they typecast for the function
> new_emp().
>
> I have tried
> <same query>
> where author=::$1...
>
> and get the same error message.
>
> Can somebody help me on typecasting?
>
> Kostas Vassiliadis
>
>
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: djackson@cpsgroup.com, vassilik@p22.cs.man.ac.uk
Subject: Re: [SQL] Typecasting in SQL functions
In-Reply-To: <F10BB1FAF801D111829B0060971D839F33315F@cpsmail>
References: <F10BB1FAF801D111829B0060971D839F33315F@cpsmail>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox