- 论坛徽章:
- 0
|
我看了文档,但不怎么明白,我写了个函数是查找表中有相同密码的用户,函数是这样的:
- CREATE OR REPLACE FUNCTION webhouse.test_cursor(userpw "varchar")
- RETURNS refcursor AS
- $BODY$
- declare
- admin_name refcursor;
- myname varchar;
- begin
- set search_path to webhouse;
- open admin_name for select "adminUserName" from "AdminUser" where "adminUserPW"=$1;
-
- RETURN admin_name;
- end;
- $BODY$
- LANGUAGE 'plpgsql' VOLATILE;
复制代码
那我应该怎样用才对呢?
- set search_path to webhouse;
- select test_cursor('123456');
- fetch all from admin_name;
复制代码
这样子用报:
- 查询结果,舍弃 1 列。
- ERROR: cursor "admin_name" does not exist
复制代码
麻烦请高手指点一下,我以前只用过mysql(没有游标),现在想学全面一点 |
|