X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id AC96C52896 for ; Fri, 3 Jun 2005 11:44:58 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 82201-01 for ; Fri, 3 Jun 2005 14:44:56 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.203]) by svr1.postgresql.org (Postfix) with ESMTP id 1208652894 for ; Fri, 3 Jun 2005 11:44:55 -0300 (ADT) Received: by wproxy.gmail.com with SMTP id 49so116359wri for ; Fri, 03 Jun 2005 07:44:59 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=lDz9irBKx5EnDvZMY77GbTp6v8asw81aFR8CyH1Ec0LOrGioIUxlD9icb0dKa3/MNC9kAN5ylCx72+c+/b5GF5Y5RIRMJNlm86jwRqfy1idEuwf8Nv5LehPMOJOwztDkzIpF+Q/fRRgXhcLHsah9hVAVzjBbnFEIkuYVYFcT8UE= Received: by 10.54.20.7 with SMTP id 7mr88622wrt; Fri, 03 Jun 2005 07:44:59 -0700 (PDT) Received: by 10.54.20.42 with HTTP; Fri, 3 Jun 2005 07:44:59 -0700 (PDT) Message-ID: <87eeecff0506030744e04eb25@mail.gmail.com> Date: Fri, 3 Jun 2005 17:44:59 +0300 From: Ami Ganguli Reply-To: Ami Ganguli To: pgsql-sql@postgresql.org Subject: using a selected row as a function parameter Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.024 tagged_above=0 required=5 tests=RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200506/49 X-Sequence-Number: 21650 Hi all, I've been struggling with this for a while and haven't found anything on the 'Net about it. I've created a function that takes two table rows as a parameters. I'd like to use the output of a select (two single rows) as the parameters, but I can't get it to work. What am I missing? The function prototype looks like this: CREATE OR REPLACE FUNCTION queue.apply_routing_rule( queue.messages,=20 queue.routing_rules ) RETURNS int2 and I would like to call it like this: SELECT queue.apply_routing_rule(=20 (SELECT * from queue.messages WHERE id =3D 1), (SELECT * from queue.routing_rules WHERE id =3D 1) ); I get an error message along the lines of "sub-query must return a single value". I've tried different combinations of "CAST" and "ROW" functions, but they give syntax errors. Any suggestions? Regards, Ami.