文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>Extending the Database: PL/pgSQL

Extending the Database: PL/pgSQL

时间:2010-01-23  来源:admin126com

Extending the Database: PL/pgSQL

* PostgreSQL offers two interpreted languages in which one can write SQL functions: PL/pgSQL and PL/tcl. More can be added by the user by coding the appropriate stub.

* PL/pgSQL Example:

As user postgres:

test=> CREATE FUNCTION plpgsql_call_handler () 
test-> RETURNS OPAQUE
test-> AS '/usr/lib/pgsql/plpgsql.so'
test-> LANGUAGE 'c' \g
CREATE
test=>
test=> CREATE TRUSTED PROCEDURAL LANGUAGE 'plpgsql'
test-> HANDLER plpgsql_call_handler
test-> LANCOMPILER 'PL/pgSQL' \g
CREATE

As user shlomi:

test=> CREATE FUNCTION num_descendants (int4)
test-> RETURNS int4 AS
test-> '
test'>     DECLARE
test'>         key ALIAS for $1;
test'>         num int4;
test'>         child RECORD;
test'>     BEGIN
test'>         num := 0;
test'>         FOR child IN SELECT c FROM par_kids WHERE p = key LOOP
test'>             num := num + 1 + num_descendants(child.c);
test'>         END LOOP;
test'>         RETURN num;
test'>     END;
test'> '
test-> LANGUAGE 'plpgsql' \g
CREATE
test=> SELECT num_descendants(1) \g
num_descendants
---------------
              9
(1 row)
相关阅读 更多 +
排行榜 更多 +
跳舞的线无尽版游戏下载

跳舞的线无尽版游戏下载

休闲益智 下载
西电睿思手机版app下载

西电睿思手机版app下载

生活实用 下载
Polkadot币最具跨链互通的交易所币安下载

Polkadot币最具跨链互通的交易所币安下载

金融理财 下载