Passing result of multirow subquery to C function

From: Magnus Persson <magnus(dot)e(dot)persson(at)gmail(dot)com>
To: PgSQL Novice <pgsql-novice(at)postgresql(dot)org>
Subject: Passing result of multirow subquery to C function
Date: 2013-12-31 16:14:11
Message-ID: 52C2ED53.202@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

During the holidays I've taken on to looking at writing a postgres C
extension/function. What I've done so far is more or less the article
series by Ron Peterson (http://linuxgazette.net/142/peterson.html)

What I'm having issues figuring out is how to pass the results of a
subquery to a function (if at all possible?):

SELECT hello((SELECT name FROM names));

Where name is of type TEXT. And results from calling the function is:

hello
------------
Hello, Benny
Hello, Kenny

And what the function does is to only prepend "Hello, " to the string.

My naive attempt errors with:
ERROR: more than one row returned by a subquery used as an expression

What should I be looking at?

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message David Johnston 2013-12-31 16:24:09 Re: Passing result of multirow subquery to C function
Previous Message Tanstaafl 2013-12-31 15:19:28 Re: Reliably backing up a live database