Re: How to test a function in pgAdmin? - Mailing list pgsql-novice

From Bob
Subject Re: How to test a function in pgAdmin?
Date
Msg-id 762e5c0609251934i38901e5euf727e88094b9362a@mail.gmail.com
Whole thread Raw
In response to How to test a function in pgAdmin?  ("Jacques Koorts" <jacques@vine.co.za>)
List 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@vine.co.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


pgsql-novice by date:

Previous
From: "Roberto Saban"
Date:
Subject: cross-database partitioning.
Next
From: Michael Fuhr
Date:
Subject: Re: pass date type data to PQexecparams