Oracle存储过程----存储过程执行简单的增删改查


1、存储过程执行增加的sql

create or replace procedure test_add(id varchar,name varchar,time varchar,age varchar,sex varchar) is
begin
insert into table(id,name,time,varchar,age,sex);
commit;
end;
执行语句如下:
set serveroutput on;
call test_add('01','zhangsan','2019-06-21','22','');

2、存储过程执行修改的sql

create or replace procedure test_update(id varchar,mc varchar)is
begin
update ly_tb set  ly_mc where ly_id = id;
commit;
end;


执行语句如下:
set serveroutput on;
call test_update('02','lisi');
end;

3、存储过程执行查询的sql

create or replace procedure test_select(sex varchar)is
begin
countNum number(10);
maxId      number(10);
begin
select  count(*),max(id) into countNum,maxId from ly_tb where ly_nb=sex;
dbms_output.putline(countNum);
dbms_output.put_line(maxId);
end;

注意:进行查询的时候此方式只能查询一条数据,如果查询结果返回的结果集,需要用到游标(cursor)。


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM