pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ami Ganguli <ami.ganguli@gmail.com>
To: pgsql-sql@postgresql.org
Subject: using a selected row as a function parameter
Date: Fri, 3 Jun 2005 17:44:59 +0300
Message-ID: <87eeecff0506030744e04eb25@mail.gmail.com> (raw)

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, 
                       queue.routing_rules
                       ) RETURNS int2

and I would like to call it like this:

SELECT queue.apply_routing_rule( 
                      (SELECT * from queue.messages WHERE id = 1),
                      (SELECT * from queue.routing_rules WHERE id = 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.



view thread (3+ messages)  latest in thread

Message-ID: <87eeecff0506030744e04eb25@mail.gmail.com>
Permalink:  ../87eeecff0506030744e04eb25@mail.gmail.com/
Also on:    postgresql.org/message-id/87eeecff0506030744e04eb25@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: ami.ganguli@gmail.com
  Subject: Re: using a selected row as a function parameter
  In-Reply-To: <87eeecff0506030744e04eb25@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox