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.