+ -
当前位置:首页 → 问答吧 → 存储过程创建与调用

存储过程创建与调用

时间:2011-12-14

来源:互联网

create or replace procedure proc_test(testchar in number,testdae out date)
as
begin
 select sysdate into testdae from dual;
 dbms_output.put_line('in 参数:'||testchar||'out参数:'||testdae);
 insert into b(b,testchar,testtype) values(capablity_seq.nextval,testchar,testdae);
end proc_test;


这是我创建的一个最基本的存储过程,是OK的,但在执行时报错,
执行的方式

execute proc_test(234);
然后就总报错,这个参数应该如何传递啊。。。。。。

作者: ZWJ1988   发布时间: 2011-12-14

SQL code
declare
  vs_char varchar2(10) := '234'
  vd_date date;
begin
  proc_test(vs_char, vd_date);
  dbms_output.putline(to_char(vd_date,'yyyymmdd'));
end;

作者: yixilan   发布时间: 2011-12-14

create or replace procedure proc_test(testchar in number,testdae out date)
两个参数,
testchar是传入参数
testdae是传出参数

作者: rainbow_han   发布时间: 2011-12-14

insert 之后 最好是 commit一下。
还有异常的捕获也是必须的、
SQL code

/*create or replace procedure proc_test(testchar in number,testdae out date)
as
begin
 testdae:=sysdate;
 dbms_output.put_line('in 参数:'||testchar||'out参数:'||testdae);
 insert into b(b,testchar,testtype) 
 values(1,testchar,testdae);
 commit;
end proc_test;
*/


declare 
my_testdae date;
begin 
   proc_test(234,my_testdae);
  dbms_output.put_line(my_testdae);
end ;

/*create table b
(
  b number,
  testchar number,
  testtype date
)*/

select * from b

作者: lxpbs8851   发布时间: 2011-12-14

testdae 把传出参数声明一个变量

作者: lfz860110   发布时间: 2011-12-14


PLS-00103:Encountered the symbol 'TEST'when expection one of the following :=.(@ %;The symbol ":=" was substituted for 'Test' to continus;


这个错误有见过吗???

作者: ZWJ1988   发布时间: 2011-12-14

引用 5 楼 zwj1988 的回复:
PLS-00103:Encountered the symbol 'TEST'when expection one of the following :=.(@ %;The symbol ":=" was substituted for 'Test' to continus;


这个错误有见过吗???

出错的过程帖出来啊

作者: lxpbs8851   发布时间: 2011-12-14

就是我上面的那个,我已经找到原因了,去掉exec,直接写过程名就OK了,
但我还是不知道为什么一定要去掉了exec呢???

作者: ZWJ1988   发布时间: 2011-12-14

热门下载

更多