pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedProbs with int2 in functions
4+ messages / 3 participants
[nested] [flat]
* Probs with int2 in functions
@ 1998-12-27 06:56 Gordon Clarke <gordonc@cyberbiz.net.au>
0 siblings, 1 reply; 4+ messages in thread
From: Gordon Clarke @ 1998-12-27 06:56 UTC (permalink / raw)
To: pgsql-sql
I'm using PostgreSQL v6.3.2.
It appears that the function command doesn't like the type "int2" as a
parm in a call. For example,
zedadmin=> \i zz.sql
create table test2(
trk_id int2 not null,
trk_nm varchar(30) not null,
trk_comp varchar(30));
CREATE
create function insert_test2(int2,varchar,varchar)
returns int4 as
'insert into test2
values($1,$2,$3);
select 1 as return_val;'
language 'sql';
CREATE
EOF
The objects are successfully created, but when I come to insert data via
the function there is the following error.
zedadmin=> select insert_test2(1,'My name','My comment');
ERROR: function insert_test2(int4, unknown, unknown) does not exist
If one changes the int2 to an int4 in the table and function, the function
is happy to insert the data into the table.
Any ideas why this is so, or is it a bug?
Cheers...Gordon
~~~~~~~~~~~~~~ 4ZzZ Brisbane's First Community FM Station ~~~~~~~~~~~~~~
The Demo Show - Supporting Australian Unsigned Artists
Mon nights 6-7pm (0800-0900UTC) on 4ZzZ 102.1 FM
http://www.4zzzfm.org.au/welcome.html (RA feed)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: [SQL] Probs with int2 in functions
@ 1998-12-29 14:03 Jose' Soares <jose@sferacarta.com>
parent: Gordon Clarke <gordonc@cyberbiz.net.au>
0 siblings, 1 reply; 4+ messages in thread
From: Jose' Soares @ 1998-12-29 14:03 UTC (permalink / raw)
To: Gordon Clarke <gordonc@cyberbiz.net.au>; +Cc: pgsql-sql
Gordon Clarke wrote:
>
> I'm using PostgreSQL v6.3.2.
>
> It appears that the function command doesn't like the type "int2" as a
> parm in a call. For example,
>
> zedadmin=> \i zz.sql
> create table test2(
> trk_id int2 not null,
> trk_nm varchar(30) not null,
> trk_comp varchar(30));
> CREATE
>
> create function insert_test2(int2,varchar,varchar)
> returns int4 as
> 'insert into test2
> values($1,$2,$3);
> select 1 as return_val;'
> language 'sql';
> CREATE
> EOF
>
> The objects are successfully created, but when I come to insert data via
> the function there is the following error.
>
> zedadmin=> select insert_test2(1,'My name','My comment');
> ERROR: function insert_test2(int4, unknown, unknown) does not exist
>
> If one changes the int2 to an int4 in the table and function, the function
> is happy to insert the data into the table.
>
> Any ideas why this is so, or is it a bug?
>
It works on my v6.4:
select insert_test2(1,'My name','My comment');
insert_test2
------------
1
(1 row)
select * from test2;
trk_id|trk_nm |trk_comp
------+-------+----------
1|My name|My comment
1|My name|My comment
(2 rows)
Any way try to cast values as:
select insert_test2(1::int2,'My name'::varchar,'My comment'::varchar);
-Jose'-
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: [SQL] Probs with int2 in functions
@ 1999-01-03 06:02 Gordon Clarke <gordonc@cyberbiz.net.au>
parent: Jose' Soares <jose@sferacarta.com>
0 siblings, 0 replies; 4+ messages in thread
From: Gordon Clarke @ 1999-01-03 06:02 UTC (permalink / raw)
To: sferac@bo.nettuno.it; +Cc: pgsql-sql
On Tue, 29 Dec 1998, Jose' Soares wrote:
> > The objects are successfully created, but when I come to insert data via
> > the function there is the following error.
> >
> > zedadmin=> select insert_test2(1,'My name','My comment');
> > ERROR: function insert_test2(int4, unknown, unknown) does not exist
> >
> > If one changes the int2 to an int4 in the table and function, the function
> > is happy to insert the data into the table.
> >
> > Any ideas why this is so, or is it a bug?
> >
>
> It works on my v6.4:
>
> select insert_test2(1,'My name','My comment');
> insert_test2
> ------------
> 1
> (1 row)
So it appear that it is a bug in 6.3.2!
> Any way try to cast values as:
> select insert_test2(1::int2,'My name'::varchar,'My comment'::varchar);
I'd prefer not to do that. Also, since it isn't necessary for the int4
case then it shouldn't be for the int2 case and this suggests to me that
it is a bug.
Thanks for your suggestions and help.
Cheers...Gordon
~~~~~~~~~~~~~~ 4ZzZ Brisbane's First Community FM Station ~~~~~~~~~~~~~~
The Demo Show - Supporting Australian Unsigned Artists
Mon nights 6-7pm (0800-0900UTC) on 4ZzZ 102.1 FM
http://www.4zzzfm.org.au/welcome.html (RA feed)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
^ permalink raw reply [nested|flat] 4+ messages in thread
* RE: [SQL] Probs with int2 in functions
@ 1999-01-04 23:40 Jackson, DeJuan <djackson@cpsgroup.com>
0 siblings, 0 replies; 4+ messages in thread
From: Jackson, DeJuan @ 1999-01-04 23:40 UTC (permalink / raw)
To: Gordon Clarke <gordonc@cyberbiz.net.au>; sferac@bo.nettuno.it; +Cc: pgsql-sql
Well, it's not really a bug. It's the lack of a feature. Constant
integers are simply int4's not int2's and in pre-v6.4 the was no
auto-type coercion. The key here is 'auto'. If there was no type
coercion I'd have to agree that it was a bug. But simply because the
developers didn't assume that they know what I want better than I do,
doesn't make it a bug.
So, you have to specify type conversions yourself. If you want your
function to work as is upgrade.
-DEJ
> -----Original Message-----
> On Tue, 29 Dec 1998, Jose' Soares wrote:
>
> > > The objects are successfully created, but when I come to
> insert data via
> > > the function there is the following error.
> > >
> > > zedadmin=> select insert_test2(1,'My name','My comment');
> > > ERROR: function insert_test2(int4, unknown, unknown)
> does not exist
> > >
> > > If one changes the int2 to an int4 in the table and
> function, the function
> > > is happy to insert the data into the table.
> > >
> > > Any ideas why this is so, or is it a bug?
> > >
> >
> > It works on my v6.4:
> >
> > select insert_test2(1,'My name','My comment');
> > insert_test2
> > ------------
> > 1
> > (1 row)
>
> So it appear that it is a bug in 6.3.2!
>
> > Any way try to cast values as:
> > select insert_test2(1::int2,'My name'::varchar,'My
> comment'::varchar);
>
> I'd prefer not to do that. Also, since it isn't necessary for the int4
> case then it shouldn't be for the int2 case and this suggests
> to me that
> it is a bug.
>
> Thanks for your suggestions and help.
>
> Cheers...Gordon
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~1999-01-04 23:40 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1998-12-27 06:56 Probs with int2 in functions Gordon Clarke <gordonc@cyberbiz.net.au>
1998-12-29 14:03 ` Jose' Soares <jose@sferacarta.com>
1999-01-03 06:02 ` Gordon Clarke <gordonc@cyberbiz.net.au>
1999-01-04 23:40 RE: [SQL] Probs with int2 in 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