使用oracle的存储过程的例子
十几年没有用oracle的存储过程了,有些东西已经忘了,没有想到今天又要用。在这里写个例子。 create or replace procedure wanglc_test is v_table_name varchar2(50); v_sql varchar2(4000); cursor cur_get_users is select username,created from all_users; v_username varchar2(50); v_created date; begin dbms_output.put_line(to_char(sysdate,‘yyyy-mm-dd hh24:mi:ss‘) || ‘ call procedure wanglc_test begin...‘); open cur_get_users; loop fetch cur_get_users into v_username,v_created; exit when cur_get_users%notfound; dbms_output.put_line(to_char(sysdate,‘yyyy-mm-dd hh24:mi:ss‘) || ‘ ‘ || v_username || ‘ -- ‘ || v_created); if (v_username = ‘SYS‘ or v_username = ‘SYSTEM‘) then dbms_output.put_line(to_char(sysdate,‘yyyy-mm-dd hh24:mi:ss‘) || ‘ ‘ || v_username || ‘ is DBA!!!‘); /* insert into sys_user(name,created) values(‘SYS‘,sysdate) */ v_sql := ‘insert into sys_user(name,created) values(‘‘‘ || v_username ||‘‘‘,sysdate)‘; dbms_output.put_line(to_char(sysdate,‘yyyy-mm-dd hh24:mi:ss‘) || ‘ ‘ || v_sql); execute immediate v_sql; execute immediate ‘commit‘; end if; end loop; close cur_get_users; dbms_output.put_line(to_char(sysdate,‘yyyy-mm-dd hh24:mi:ss‘) || ‘ call procedure wanglc_test end.‘); end wanglc_test; ?
在命令行执行存储过程 另外,可以在plsql developer中右键点击存储过程名称进行测试。此处略。 (编辑:淮安站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |