哪位帮写个oracle存储过程,新手入门,请不吝赐教,多谢了!

来源:百度知道 编辑:UC知道 时间:2024/09/22 07:30:22
假设有一个数据库表table1,其中有一个字段filedate是日期型,想实现输入一个该日期就显示或打印出该表filedate=输入值的部分字段(例如select 字段1,字段2 where filedate='20091117'),请问怎么写存储过程,请给出代码和使用存储过程的步骤,越详细越好。

create or replace procedure pro_test(v_yourtime in date)--建立一个名为pro_test的存储过程,并定义一个时间参数,在使用存储过程的时候就直接传参就行了
is
v_id table1.id%type,
v_name table1.name%type;
begin
select id,name into v_id,v_name from table1 where filedate=v_yourtime;
dbms_output.put_line('符合条件的id是:'||v_id||'name是:'||v_name);--这里输出id和name
--下面是定义异常
exception
when no_data_found then
dbms_output.put_line('出现异常,无数据!');
when others then
dbms_output.put_line('其他异常出现!');
end;

--------执行部分:
两种方法:
1.在命令窗口调用:Execute pro_test(to_date('20091117','yyyymmdd'));
2.在SQL窗口调用直接用就行了:
declare
begin
pro_test(to_date('20091117','yyyymmdd'));
end;

--其中有什么问题,再留言吧

create procudre 存储过程名(参数1 数据类型,参数2 数据类型)
as
begin
select 字段 into 参数1 from 表名 where empno=参数2;
end;