例子一,不带returns:

postgres=# CREATE FUNCTION sum_n_product(x int, y int, OUT sum int, OUT prod int) AS $$
postgres$# BEGIN
postgres$# sum := x + y;
postgres$# prod := x * y;
postgres$# END;
postgres$# $$ LANGUAGE plpgsql;
CREATE FUNCTION
postgres=#
postgres=# select sum_n_product(3,4);
sum_n_product
---------------
(7,12)
(1 row)

例子二,带returns:

postgres=# CREATE FUNCTION sum_n_product2(x int, y int, OUT sum int, OUT prod int) returns record AS $$
postgres$# BEGIN
postgres$# sum := x + y;
postgres$# prod := x * y;
postgres$# END;
postgres$# $$ LANGUAGE plpgsql;
CREATE FUNCTION
postgres=#
postgres=# select sum_n_product2(3,4);
sum_n_product2
----------------
(7,12)
(1 row) postgres=#

PL/pgSQL多输出参数例子的更多相关文章

  1. PL/pgSQL的RETURN QUERY例子

    我的例子: 数据准备: create table custinfo(custid integer,callingcnt integer); ,),(,),(,); 函数生成: CREATE OR RE ...

  2. PL/pgSQL的 RETURN NEXT例子

    从网上找到例子: 可以说,RETURN NEXT要用在循环中: 例子一: 数据准备: CREATE TABLE foo (fooid INT, foosubid INT, fooname TEXT); ...

  3. Oracle中使用PL/SQL如何定义参数、参数赋值、输出参数和 if 判断

    1.pl/sql如何定义参数 declare --1)定义参数 -- ban_Id number; ban_Name ); 2.pl/sql如何参数赋值 --2)参数赋值-- ban_Id :; ba ...

  4. PL/pgSQL RETURNS TABLE 例子

    实验如下: RETURNS TABLE 中的变量名和SQL文中的变量名同名时,执行时会出错: pgsql=# create table sales(itemno integer,quantity in ...

  5. PL/pgSQL学习笔记之七

    http://www.postgresql.org/docs/9.1/static/plpgsql-declarations.html 如果一个PL/pgSQL函数声明了输出参数,输出参数被赋予$n名 ...

  6. PL/pgSQL学习笔记之八

    http://www.postgresql.org/docs/9.1/static/plpgsql-declarations.html 另外一种声明 PL/pgSQL 函数的方法是使用 returns ...

  7. PL/pgSQL学习笔记之三

    http://www.postgresql.org/docs/9.1/static/plpgsql-overview.html 39.1.2. Supported Argument and Resul ...

  8. PostgreSQL存储过程(2)-基于PL/PgSQL的存储过程

    介绍 PL/pgSQL 是PostgreSQL 数据库系统的一个可加载的过程语言. PL/pgSQL 的设计目标是创建一种可加载的过程语言,可以 用于创建函数和触发器过程, 为SQL 语言增加控制结构 ...

  9. Entity Framework 6 Recipes 2nd Edition(10-2)译 -> 返回输出参数

    10-2. 返回输出参数 问题 想获取存储过程里的一个或多个输出参数的值 解决方案 假设我们有一个像Figure 10-1所示的,出租车辆与租金收入的模型 Figure 10-1.出租车辆与租金收入的 ...

随机推荐

  1. Android中垃圾回收日志信息

    原因 GC_CONCURRENTfreed 178K, 41% free 3673K/6151K, external 0K/0K, paused 2ms+2msGC_EXPLICITfreed 6K, ...

  2. linux实现自动远程备份(scp+ssh)

    刚上线的服务器需要备份日志,要备份到另一台服务器上去,为了减少工作量,采用linux的定时任务去自动执行.因服务器都是linux的,因此采用linux的远程复制scp命令.但这里涉及到一个问题,就是s ...

  3. MSDN 中 对vector::erase()的解释.xml

    pre{ line-height:1; color:#f0caa6; background-color:#2d161d; font-size:16px;}.sysFunc{color:#e54ae9; ...

  4. 【LeetCode】139 - Word Break

    Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separa ...

  5. linux nginx安装(转载)

    1.linux 下面安装 1.下载 pcre-8.10.tar.gz  nginx-1.1.1.tar.gz 2.安装 pcre 让nginx支持rewrite pcre-8.10.tar.gz  上 ...

  6. asp.net mvc 使用Ajax

    使用asp.net mvc 调用Action方法很简单. 一.无参数方法. 1.首先,引入jquery-1.5.1.min.js 脚本,根据版本不同大家自行选择. <script src=&qu ...

  7. Ubuntu 上安装R

    1. 编辑 /etc/apt/sources.listsudo cp /etc/apt/sources.list /etc/apt/sources.list.backupsudo gedit sour ...

  8. hadoop中HBase子项目入门讲解

    HBase 是Hadoop的一个子项目,HBase采用了Google BigTable的稀疏的,面向列的数据库实现方式的理论,建立在hadoop的hdfs上,一方面里用了hdfs的高可靠性和可伸缩行, ...

  9. something: 重构、正则、vim -- clwu

    项目需要做一个db table 操作的小工具. 从phpMyAdmin上拷贝了一些代码过来修改,但我有没有足够的时间把所有拷贝过来的代码都重构修改和测试完,于是希望后面接手的同事在需要修改这些代码时能 ...

  10. mysql cluster 名词概念解读

    Node Group [number_of_node_groups] = number_of_data_nodes / NoOfReplicas Partition When using ndbd, ...