摘要:
建立表:CREATE TABLE sal_emp (name text,pay_by_quarter integer[],schedule text[][]);插入数据:INSERT INTO sal_emp VALUES ('Bill', ARRAY[10000, 11000, 9000, 13000], ARRAY[['meeting', 'lunch'], ['training', 'presentation']]);INSERT INTO sal_emp VALUES ('Carol', A 阅读全文
摘要:
http://www.postgresonline.com/journal/archives/239-The-wonders-of-Any-Element.html定义函数pgsql=# CREATE OR REPLACE FUNCTION diff_inc(IN anyelement, IN anyelementpgsql(# , OUT diff integer, OUT f_val anyelement, OUT l_val anyelement)pgsql-# RETURNS recordpgsql-# ASpgsql-# $$pgsql$# BEGINpgsql$# dif... 阅读全文
摘要:
实验如下:RETURNS TABLE 中的变量名和SQL文中的变量名同名时,执行时会出错:pgsql=# create table sales(itemno integer,quantity integer,price numeric);CREATE TABLEpgsql=# insert into sales values (100,15,11.2),(101,22,12.3);INSERT 0 2pgsql=# CREATE FUNCTION extended_sales(p_itemno int)pgsql-# RETURNS TABLE(quantity int, total nume 阅读全文