例子一,不带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. 【转】ACE编程小结

    转自:http://blog.csdn.net/mjp_mjp/article/details/4406059 1.多线程中的ACE_Reactor::EventLoop,当在多线程(池)中调用Eve ...

  2. 简易nagios安装出现的问题及解决方法

    安装时候所遇到的问题: A 安装PHP的时候报错xml2-config未找到 安装PHP的时候报错:未找到包libxml2 解决方法:安装libxml2包即可,libxml2是php的依赖包,从而需要 ...

  3. motan源码解读:注册中心zookeeper(1)

    Apache ZooKeeper is an effort to develop and maintain an open-source server which enables highly rel ...

  4. 时间日期Date类型

    <!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8& ...

  5. 学习内容:Html5+Axure原型设计

    今日主要在http://www.runoob.com/html/html5-intro.html和http://www.imooc.com/learn/9网站上学习Html的知识,head.title ...

  6. windows下跑python flask,环境配置

    首先声明一下,我安装的是python 2.7. 第一步:下载easy_setup.py 下载地址:https://pypi.python.org/pypi/setuptools 这个下载地址真心难找, ...

  7. Java的平台无关性

    转载自:http://www.cnblogs.com/Y/archive/2011/03/22/JavaVM_Learning_Chapter2_Platform_Independence.html ...

  8. Python:数字

    一.数字简介 数字可以直接访问,是不可更改并且不可分割的原子类型,这些在标准类型的分类中都谈到了.不可更改意味着变更数字值的实质是新对象的创建.当然,这些对于程序员来说都是透明的,不需过多考虑. 1. ...

  9. 关于Bean

    什么是Bean? 一个Bean 就是一个类.我们不必为制造任何的Bean而编写一些特殊的代码或者使用特殊的编程语言.事实上,我们唯一需要做的是略微地修改我们对我们方法命名的办法.方法名通知应用程序构建 ...

  10. initWithSpriteFrameName和createWithSpriteFrameName

    /** * Initializes a sprite with a sprite frame name. <br/> * A cc.SpriteFrame will be fetched ...