站点信息 访问统计:442656     在线人数:1    本次启动时间:2010-9-11 5:35:42
当前位置:  Csdtn 首页->数据库->存储过程->文章
经验分享:Informix和Oracle存储过程的异同
作者:--- 时间:2009-3-1  点击:162  本文Tag:数据库 | Oracle | 存储过程

在工作过程中涉及到过有时要进行INFORMIX和ORACLE之间的移植,有时应用需要既支持INFORMIX数据库又要支持ORACLE数据库,如果应用程序涉及到存储过程的话,就需要既熟悉INFORMIX存储过程的写法,又需要熟悉ORACLE存储过程的写法。笔者将在工作中总结的一些经验写出来与大家共享。

建立存储过程的语法:


一、Informix


create procedure proc_name( [....in_parameter_list])


returning out_para_list / out_result_set;


二、Oracle


create [or replace] procedure procedue_name


[ (arg1 [ {in | out | in out }] type


(argn [ {in | out | in out }] type,)]


{is | as} --代替DECLARE关键字


[ 变量定义区]


begin


end procedure_name;


三、几个简单的例子


1、没有参数也没有返回值


1)Informix


create procedure pNoParam()


begin


on exception


rollback work;


return;


end exception


begin work;


delete from t1;


delete from t2;


commit work;


end;


end procedure;


2)Oracle


create or replace procedure pNoParam


as


begin


delete from t1;


delete from t2;


commit;


exception


when others then


begin


rollback;


end;


end pNoParam;


2、有输入输出


往t1表中插入一条记录,返回值表示插入是否成功。


1)Informix


create procedure pNormalParam(f1 integer, f2 varchar(10))

returning integer;


begin


on exception


rollback work;


return -1;


end exception

begin work;


insert into t1 values(f1, f2);


commit work;


return 0;


2)Oracle


create or replace procedure pNormalParam(f1 number,

f2 varchar2, v_Result out number)


as


begin


insert into t1 values(f1,f2);


commit;


v_Result = 0;


return;


exception


when others then


begin


rollback;


v_Result := -1;


end;


end pNormalParam;


需要注意的是,在oracle存储过程中,参数是不能加上size的,比如f1,在t1表中该字段是number(10,0),而这里只能写number,而不能写number(10,0)。

Google
 

 


运行时错误

“/”应用程序中的服务器错误。

运行时错误

说明: 服务器上出现应用程序错误。此应用程序的当前自定义错误设置禁止远程查看应用程序错误的详细信息(出于安全原因)。但可以通过在本地服务器计算机上运行的浏览器查看。

详细信息: 若要使他人能够在远程计算机上查看此特定错误消息的详细信息,请在位于当前 Web 应用程序根目录下的“web.config”配置文件中创建一个 <customErrors> 标记。然后应将此 <customErrors> 标记的“mode”属性设置为“Off”。


<!-- Web.Config 配置文件 -->

<configuration>
    <system.web>
        <customErrors mode="Off"/>
    </system.web>
</configuration>

注释: 通过修改应用程序的 <customErrors> 配置标记的“defaultRedirect”属性,使之指向自定义错误页的 URL,可以用自定义错误页替换所看到的当前错误页。


<!-- Web.Config 配置文件 -->

<configuration>
    <system.web>
        <customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
    </system.web>
</configuration>