View Single Post

   
  #1 (permalink)  
Old 05-07-2008, 10:18 AM
John Gunther
 
Posts: n/a
Default why am I told "subquery must return only one column"

I'm sure I'm making some bonehead syntax error but after an hour of
reading, searching, and experimenting it's time to ask wiser heads:

I've defined a type m
create type m as (m1 int,m2 int,m3 int,m4 int);

and a function sub:
create function sub(m) returns int as 'select (2*$1.m1 +3*$1.m2 +4*$1.m3
+ 5*$1.m4);' language sql;

and trying to create a second function mstr that calls the sub function
using a select statement as sub's argument:
create function mstr(text,text) returns int as 'select sub((select
5,6,7,8)::m);' language sql;

The last operation (and many variations of it) yields:
ERROR: subquery must return only one column

My question is this:
(select 5,6,7,8)::m returns a single entity of composite type m and sub
takes one argument of type m. So why the error? I don't even think the
::m is required.

Thanks in advance.

John Gunther
Bucks vs Bytes Inc.

--
Sent via pgsql-novice mailing list (pgsql-novice@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-novice

Reply With Quote