本人刚刚接触存储过程方面的设计,在编写地方不太懂。我现在的情况是这样的:我创建了一个存储过程字段代码如下 (
plateid in Varchar2,
platecolor in Varchar2,
platetype in Varchar2,
crossingtime in Date,
crossingname in Varchar2,
aspectname in Varchar2,
wayname in Varchar2,
speed in Varchar2,
illegaltype in Number,
blackstate in Number,
filepath1 in Varchar2,
filepath2 in Varchar2,
filepath3 in Varchar2,
filepath4 in Varchar2,
result_blackstate out Number,
result_plateid out Number
)
as
begin
commit;
end;需要插入以上字段的表名为:
tb_plate;tb_illegalcar;tb_normalcar需要考虑的问题:
1:plateid,platecolor,platetype;这3个字段要放入表tb_plate,而且表里的plateid有唯一约束,如发现相同数据返回1。返回的字段是result_plateid。
2:crossingtime,crossingname,aspectname,wayname,speed,illegaltype,filepath1,filepath2,filepath3,filepath4;这些字段要同时插入到tb_illegalcar和tb_normalcar两表当中插入这2表的判断条件是:当illegaltype=1时插入到tb_normalcar,当illegaltype=其他数字时插入到tb_illegalcar表里。
3:在操作2中还要判断blackstate的值,如果blackstate=1那么当前信息插入到tb_normalcar表里,blackstate=2那么当前信息插入到tb_illegalcar,blackstate=3那么舍弃这条信息。
4:2和3的判断条件是并列存在的。都需要去判断。因为考虑的地方很多,需要判断的也很多。但是begin和end中间怎么写我还实在不太会。希望得到解答.
plateid in Varchar2,
platecolor in Varchar2,
platetype in Varchar2,
crossingtime in Date,
crossingname in Varchar2,
aspectname in Varchar2,
wayname in Varchar2,
speed in Varchar2,
illegaltype in Number,
blackstate in Number,
filepath1 in Varchar2,
filepath2 in Varchar2,
filepath3 in Varchar2,
filepath4 in Varchar2,
result_blackstate out Number,
result_plateid out Number
)
as
begin
commit;
end;需要插入以上字段的表名为:
tb_plate;tb_illegalcar;tb_normalcar需要考虑的问题:
1:plateid,platecolor,platetype;这3个字段要放入表tb_plate,而且表里的plateid有唯一约束,如发现相同数据返回1。返回的字段是result_plateid。
2:crossingtime,crossingname,aspectname,wayname,speed,illegaltype,filepath1,filepath2,filepath3,filepath4;这些字段要同时插入到tb_illegalcar和tb_normalcar两表当中插入这2表的判断条件是:当illegaltype=1时插入到tb_normalcar,当illegaltype=其他数字时插入到tb_illegalcar表里。
3:在操作2中还要判断blackstate的值,如果blackstate=1那么当前信息插入到tb_normalcar表里,blackstate=2那么当前信息插入到tb_illegalcar,blackstate=3那么舍弃这条信息。
4:2和3的判断条件是并列存在的。都需要去判断。因为考虑的地方很多,需要判断的也很多。但是begin和end中间怎么写我还实在不太会。希望得到解答.
解决方案 »
- oracle字符连接函数concat与||有什么区别
- 现在学习oracle是选10g还是11g
- 3个字段group by,去掉统计<200的分组,然后再统计的sql语句的问题!
- delphi 调用oracle带游标的存储过程?!
- sql实现按照序号奇数、偶数生成新结果集
- 关于在oracle存储过程里取出自增字段值的问题,相当于sql server @@identity
- 数据库恢复,急!
- 高分求一条简单的SQL语句(顶者有份)
- 这样的查询怎么写SQL语句?
- 搞分寻找ASP+oracle高手!如何实现客户端的图片存到远程数据库oracle中的BLOB字段中?
- 求救--关于安装oracle 10G客户端,安装界面出不来的原因
- 菜鸟问个小问题。
(
plateid in Varchar2,
platecolor in Varchar2,
platetype in Varchar2,
crossingtime in Date,
crossingname in Varchar2,
aspectname in Varchar2,
wayname in Varchar2,
speed in Varchar2,
illegaltype in Number,
blackstate in Number,
filepath1 in Varchar2,
filepath2 in Varchar2,
filepath3 in Varchar2,
filepath4 in Varchar2,
result_blackstate out Number,
result_plateid out Number
)
as
v_count number;
begin
select count(*) into v_count from tb_plate where plateid=plateid ;
if v_count>0 then
result_blackstate:=1;
result_plateid:=plateid;
else
insert into tb_plate(plateid,platecolor,platetype) values(plateid,platecolor,platetype);
end if;
if illegaltype=1 and blackstate=2 then
insert into tb_illegalcar(crossingtime,crossingname,aspectname,wayname,speed,illegaltype,filepath1,filepath2,filepath3,filepath4) values(
crossingtime ,
crossingname ,
aspectname ,
wayname ,
speed ,
illegaltype ,
blackstate ,
filepath1 ,
filepath2 ,
filepath3 ,
filepath4 );
else
if blackstate=1 and illegaltype=2 then
insert into tb_normalcar(crossingtime,crossingname,aspectname,wayname,speed,illegaltype,filepath1,filepath2,filepath3,filepath4) values(
crossingtime ,
crossingname ,
aspectname ,
wayname ,
speed ,
illegaltype ,
blackstate ,
filepath1 ,
filepath2 ,
filepath3 ,
filepath4 );
end if;
end if;
end;
if <条件表达式> then
<语句1>;
else
<语句2>;
end if;
看看PL/SQL基础的东西
推荐一本书:精通Oracle 10g PL/SQL编程