PL/pgSQL的RETURN QUERY例子
2013-07-09 14:41
69 查看
我的例子:
数据准备:
函数生成:
执行结果:
数据准备:
create table custinfo(custid integer,callingcnt integer); insert into custoinfo valuse(1,10),(2,6),(3,8);
函数生成:
CREATE OR REPLACE FUNCTION get_callingcnt(custid int) RETURNS TABLE ( custid int ,callingcnt int ) AS $$ BEGIN RETURN QUERY SELECT t.custid ,t.callingcnt FROM custinfo t WHERE t.custid = custid; END; $$ LANGUAGE plpgsql;
执行结果:
[pgsql@localhost bin]$ ./psql psql (9.1.2) Type "help" for help. pgsql=# select get_callcnt(1); get_callcnt ------------- (1,10) (1 row) pgsql=# select get_callcnt(2); get_callcnt ------------- (2,6) (1 row) pgsql=# \q [pgsql@localhost bin]$
相关文章推荐
- PL/pgSQL RETURNS TABLE 例子
- PL/pgSQL的anyelement例子
- PL/pgSQL的 RETURN NEXT例子
- PL/pgSQL学习笔记之八
- Query 插件为什么要return this.each()
- pl/sql之savepoint小例子
- postgre 存储过程简单实用方法 (过程语言: PL/pgSQL)
- PL/Pgsql 常用字符串函数
- request.getQueryString的例子
- 使用ParamQuery制作报表的例子(来自ParamQuery网站)
- org.hibernate.NonUniqueResultException: query did not return a unique result: 2
- Oracle 编写存储过程,在pl/sql中调用编写好的存储过程例子
- 做ArcGis Query result on map例子时,出现查询窗口在地图下一层无法查询的问题
- PLS-00905: 对象 SCOTT.QUERYEMPINFO 无效;PL/SQL: Statement ignored
- 在PL/SQL DEV里面有把锁一样的按钮,点击它会跳出“these query result are not updateable,include the ROWID to get updateab
- Example of PL/pgSQL: 在用户自定义函数中用 Return Query 返回一个表
- 学习pl/sql(语句块)的几个例子
- 用例子来验证C#中执行到return语句是直接跳出方法
- pl/sql异常之zero-divide(试图被零除)小例子
- oracle 不能更新 PL/SQL 点击“edit data”报“ these query results are not updateable”