pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedTypecasting in SQL functions
4+ messages / 3 participants
[nested] [flat]
* Typecasting in SQL functions
@ 1998-07-14 12:34 Konstantinos Vassiliadis <vassilik@p22.cs.man.ac.uk>
1998-07-15 06:27 ` Re: [SQL] Typecasting in SQL functions Zsolt Varga <redax@agria.hu>
0 siblings, 1 reply; 4+ messages in thread
From: Konstantinos Vassiliadis @ 1998-07-14 12:34 UTC (permalink / raw)
To: pgsql-sql
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
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: [SQL] Typecasting in SQL functions
1998-07-14 12:34 Typecasting in SQL functions Konstantinos Vassiliadis <vassilik@p22.cs.man.ac.uk>
@ 1998-07-15 06:27 ` Zsolt Varga <redax@agria.hu>
0 siblings, 0 replies; 4+ messages in thread
From: Zsolt Varga @ 1998-07-15 06:27 UTC (permalink / raw)
To: pgsql-sql
On Tue, 14 Jul 1998, Konstantinos Vassiliadis wrote:
|Hi,
|I have the following
|
|create table reference
|(author text,
| journal text);
|
|create table subref
| (ref reference);
what it means when a field type another table
???
what the reason for it?
redax
.----------------------------------------------------------.
|Zsolt Varga | tel/fax: +36 36 422811 |
| AgriaComputer LTD | email: redax@agria.hu |
| System Administrator | URL: http://www.agria.hu/ |
`----------------------------------------------------------'
^ permalink raw reply [nested|flat] 4+ messages in thread
* Typecasting in SQL functions
@ 1998-07-14 13:00 Konstantinos Vassiliadis <vassilik@p22.cs.man.ac.uk>
0 siblings, 0 replies; 4+ messages in thread
From: Konstantinos Vassiliadis @ 1998-07-14 13:00 UTC (permalink / raw)
To: pgsql-sql
Hi again,
please ignore my previous message regarding the creation of a function for
the relation subref
The answer to those who don't know is that you need a space between '='
and $ without the need for typecasting...
Kostas Vassiliadis
^ permalink raw reply [nested|flat] 4+ messages in thread
* RE: [SQL] Typecasting in SQL functions
@ 1998-07-15 17:43 Jackson, DeJuan <djackson@cpsgroup.com>
0 siblings, 0 replies; 4+ messages in thread
From: Jackson, DeJuan @ 1998-07-15 17:43 UTC (permalink / raw)
To: Konstantinos Vassiliadis <vassilik@p22.cs.man.ac.uk>; pgsql-sql
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
>
>
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~1998-07-15 17:43 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1998-07-14 12:34 Typecasting in SQL functions Konstantinos Vassiliadis <vassilik@p22.cs.man.ac.uk>
1998-07-15 06:27 ` Zsolt Varga <redax@agria.hu>
1998-07-14 13:00 Typecasting in SQL functions Konstantinos Vassiliadis <vassilik@p22.cs.man.ac.uk>
1998-07-15 17:43 RE: [SQL] Typecasting in SQL functions Jackson, DeJuan <djackson@cpsgroup.com>
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