Re: How to test a function in pgAdmin?

From: Bob <luckyratfoot(at)gmail(dot)com>
To: "Jacques Koorts" <jacques(at)vine(dot)co(dot)za>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: How to test a function in pgAdmin?
Date: 2006-09-26 02:34:45
Message-ID: 762e5c0609251934i38901e5euf727e88094b9362a@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Post the code you have an a usuage example makes it alot easier to
understand what you are doing.

See manual
http://www.postgresql.org/docs/8.1/interactive/plpgsql-cursors.html#PLPGSQL-CURSOR-USING

CREATE TABLE table_1 (c1 varchar(10));
INSERT INTO table_1
SELECT 'some text1';
INSERT INTO table_1
SELECT 'some text2';
select * from table_1

CREATE OR REPLACE FUNCTION myfunc(refcursor) RETURNS SETOF refcursor AS $$
BEGIN
OPEN $1 FOR SELECT * FROM table_1;
RETURN NEXT $1;
END;
$$ LANGUAGE plpgsql;

-- need to be in a transaction to use cursors.
BEGIN;
SELECT * FROM myfunc('a');
FETCH ALL FROM a;
COMMIT;

On 9/22/06, Jacques Koorts <jacques(at)vine(dot)co(dot)za> wrote:
>
> Is it possible to test a function in pgAdmin?
>
>
>
> If so then how do you test a function that returns a cursor? I only get
> "<unnamed portal 2>" when I run my function.
>
>
>
> In MSSQL you can test stored procedures that returns a "select * from
> table"
>
>
>
> Thanks for any help
>
> jk
>

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Michael Fuhr 2006-09-26 04:33:21 Re: pass date type data to PQexecparams
Previous Message Tom Lane 2006-09-25 19:07:09 Re: Multiple UNIX-domain sockets?