CREATE or REPLACE FUNCTION "sys_guid"()RETURNS "pg_catalog"."varchar" AS $BODY$DECLARE    v_seed_value varchar(32);BEGIN    select        md5(        inet_client_addr()::varchar ||timeofday() ||        inet_server_addr()::var…
-- 创建类似于Oracle中decode的函数create or replace function decode(variadic p_decode_list text[])returns text as$$declare -- 获取数组长度(即入参个数) v_len integer := array_length(p_decode_list, 1); -- 声明存放返回值的变量 v_ret text;begin /* * 功能说明:模拟Oracle中的DECODE功能(字符串处理, 其它格式…
异常处理create or replace procedure prc_get_sex (stuname student.name%type) as stusex student.sex%type; begin select sex into stusex from student where name=stuname; dbms_output.put_line('学生' || stuname || '的性别为:' || stusex); exception when too_many_rows…
IFNULL(expr1,expr2)  如果expr1不是NULL,IFNULL()返回expr1,否则它返回expr2.IFNULL()返回一个数字或字符串值,取决于它被使用的上下文环境.  mysql> select IFNULL(1,0);         -> 1 mysql> select IFNULL(0,10);         -> 0 mysql> select IFNULL(1/0,10);         -> 10 mysql> sele…
表结构 create table sys_branch ( id ) not null, parent_id ), branch_name ), delete_flag ), primary key (id) ); SELECT ID.level, b.id, b.branch_name as showName, 'branch' as itemType FROM (SELECT @ids AS _ids, (SELECT @ids := GROUP_CONCAT(id) FROM sys_br…
案例讲解 一,html片段 <div class="page-upload"> <div class="tab-wrapper2"> <span>交易结果通知</span> </div> <form id="submitForm" action="" method="post"> <input type="hidden&…
有时由于项目开发的需要,必须将SQLServer2005中的某些表同步到Oracle数据库中,由其他其他系统来读取这些数据.不同数据库类型之间的数据同步我们可以使用链接服务器和SQLAgent来实现.假设我们这边(SQLServer2005)有一个合同管理系统,其中有表contract 和contract_project是需要同步到一个MIS系统中的(Oracle9i)那么,我们可以按照以下几步实现数据库的同步.1.在Oracle中建立对应的contract 和 contract_project…
比如表结构数据如下: Table:Tree ID Name ParentId 1 一级  0 2  二级 1 3  三级 2 4 四级 3 SQL SERVER 2005查询方法: //上查 with tmpTree as ( select * from Tree where Id=2 union all select p.* from tmpTree inner join Tree p on p.Id=tmpTree.ParentId ) select * from tmpTree //下查…
简单工厂模式尽管简单,但存在一个非常严重的问题.当系统中须要引入新产品时,因为静态工厂方法通过所传入參数的不同来创建不同的产品,这必然要改动工厂类的源码,将违背"开闭原则".怎样实现添加新产品而不影响已有代码?工厂方法模式应运而生,本文将介绍另外一种工厂模式--工厂方法模式. 1 日志记录器的设计 Sunny软件公司欲开发一个系统执行日志记录器(Logger).该记录器能够通过多种途径保存系统的执行日志,如通过文件记录或数据库记录,用户能够通过改动配置文件灵活地更换日志记录方式. 在设…
在Oracle中可以使用JOB来实现一些任务的自动化执行,类似于UNIX操作系统crontab命令的功能.简单演示一下,供参考. 1.创建表T,包含一个X字段,定义为日期类型,方便后面的定时任务测试.sec@ora10g> create table t (x date); Table created. 2.创建存储过程p_insert_into_t,每次执行该存储过程都会向T表中插入一条系统当前时间.sec@ora10g> create or replace procedure p_inser…