Re: How to test a function in pgAdmin?
От | Bob |
---|---|
Тема | Re: How to test a function in pgAdmin? |
Дата | |
Msg-id | 762e5c0609251934i38901e5euf727e88094b9362a@mail.gmail.com обсуждение исходный текст |
Ответ на | How to test a function in pgAdmin? ("Jacques Koorts" <jacques@vine.co.za>) |
Список | 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;
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 по дате отправления: