On Feb 26, 2010, at 3:30 , Piyush Newe wrote:
> Hi,
>
> Consider following testcase,
>
> CREATE TABLE footable(id int4, name varchar2(10));
>
> CREATE FUNCTION foofunc(a footable, b integer DEFAULT 10)
> RETURNS integer AS $$ SELECT 123; $$ LANGUAGE SQL;
>
> CREATE FUNCTION foofunc(a footable, b numeric DEFAULT 10)
> RETURNS integer AS $$ SELECT 123; $$ LANGUAGE SQL;
>
> SELECT (footable.*).foofunc FROM footable;
> ERROR: column footable.foofunc does not exist
> LINE 1: SELECT (footable.*).foofunc FROM footable;
> ^
Is that calling syntax correct? I'd think it should be:
SELECT foofunc(footable.*, 10) FROM footable;
Note there are two arguments to foofunc (in either version)
test=# SELECT version(); version
--------------------------------------------------------------------------------------------------------------------------------------
PostgreSQL8.4.2 on i386-apple-darwin9.8.0, compiled by GCC i686-
apple-darwin9-gcc-4.0.1 (GCC) 4.0.1 (Apple Inc. build 5493), 32-bit
(1 row)
test=# CREATE TABLE footable(id int4, name varchar(10));
CREATE TABLE
test=# INSERT INTO footable (id, name) VALUES (1, 'foo'), (2, 'bar');
INSERT 0 2
test=# CREATE FUNCTION foofunc(a footable, b integer DEFAULT 10)
postgres-# RETURNS integer AS $$ SELECT 123; $$ LANGUAGE SQL;
CREATE FUNCTION
test=# CREATE FUNCTION foofunc(a footable, b numeric DEFAULT 10)
postgres-# RETURNS integer AS $$ SELECT 456; $$ LANGUAGE SQL;
CREATE FUNCTION
test=# SELECT name, foofunc(footable.*, 10) FROM footable; name | foofunc
------+--------- foo | 123 bar | 123
(2 rows)
test=# SELECT name, foofunc(footable.*, 10.0) FROM footable; name | foofunc
------+--------- foo | 456 bar | 456
(2 rows)
In any event, I couldn't get your example to work on Postgres 8.4
regardless due to the varchar2 type. Which version of Postgres are you
using?
test=# CREATE TABLE footable(id int4, name varchar2(10));
ERROR: type "varchar2" does not exist
Michael Glaesemann
grzm seespotcode net