您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

PostgreSQL存储过程初探

2024/12/12 19:44:00发布16次查看
postgresql的存储过程语法结构如下:create or replace function 函数名(参数1,[整型 int4, 整型数组 _int4, hellip;])
什么是存储过程, 百度百科是这么定义的:存储过程(stored procedure)是在大型数据库系统中,一组为了完成特定功能的sql 语句集,存储在数据库中经过第一次编译后再次调用不需要再次编译,用户通过指定存储过程的名字并给出参数(如果该存储过程带有参数)来执行它。存储过程是数据库中的一个重要对象,任何一个设计良好的数据库应用程序都应该用到存储过程。
postgresql的存储过程语法结构如下:
create or replace function 函数名(参数1,[整型 int4, 整型数组 _int4, …])
returns 返回值类型 as
$body$
declare
变量声明
begin
函数体
end;
$body$
language ‘plpgsql’ volatile;
下面的例子是要调用一个存储过程自动创建对应的一系列表:
create or replace function create_table_for_client(id int)
  returns integer as
$body$
declare
  num int4 := 0;
  sql varchar;
begin
  sql := 'create table _' || id || '_company(id int, name text)';
  execute sql;
  sql := 'create table _' || id || '_employee(id int, name text)';
  execute sql;
  sql := 'create table _' || id || '_sale_bill(id int, name text)';
  execute sql;
  .......
  return num;
end;
$body$ language plpgsql volatile
------------------------------------华丽丽的分割线------------------------------------
centos 6.3环境下yum安装postgresql 9.3
postgresql缓存详述
windows平台编译 postgresql
ubuntu下lapp(linux+apache+postgresql+php)环境的配置与安装
ubuntu上的phppgadmin安装及配置
centos平台下安装postgresql9.3
postgresql配置streaming replication集群
如何在centos 7/6.5/6.4 下安装postgresql 9.3 与 phppgadmin 
------------------------------------华丽丽的分割线------------------------------------
postgresql 的详细介绍:请点这里
postgresql 的下载地址:请点这里
本文永久更新链接地址:

该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product