Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql Novice > why am I told "...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 3 Topic 3104 of 3160
Post > Topic >>

why am I told "subquery must return only one column"

by postgresql@[EMAIL PROTECTED] (John Gunther) May 5, 2008 at 10:53 AM

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@[EMAIL PROTECTED]
)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-novice
 




 3 Posts in Topic:
why am I told "subquery must return only one column"
postgresql@[EMAIL PROTECT  2008-05-05 10:53:31 
Re: why am I told "subquery must return only one column"
tgl@[EMAIL PROTECTED] (T  2008-05-05 13:01:04 
Re: why am I told "subquery must return only one column"
postgresql@[EMAIL PROTECT  2008-05-05 14:10:35 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan13V112 Sun Jul 6 18:46:08 CDT 2008.