[color=black] 今天简单学习了下存储过程的使用,结合自己需要实现的功能,粗略的将所学所得记录如下,后续会继续完善。
CREATE OR REPLACE PROCEDURE name_p
(
)
AS
[i]--定义变量[/i]
vs_msg VARCHAR2(4000); --错误信息变量
-- 定义游标
CURSOR name_L IS
SELECT ID as ID, count - proccess as value
FROM table_name;
BEGIN
[i] -- 向表中增加一列[/i]
alert
[i] -- 遍历游标更新插入列的值[/i]
FOR rec IN name_L LOOP
UPDATE table_name t
SET REJECT_CONDITION = rec.value
WHERE t.ID = rec.ID;
END LOOP;
COMMIT;
[i] --错误处理部分[/i]EXCEPTION
WHEN OTHERS THEN
-- vs_msg := 'ERROR';
-- ROLLBACK;
--把当前错误记录进日志表。
vs_msg := 'ERROR';
ROLLBACK;
END name_p;[/color]
CREATE OR REPLACE PROCEDURE name_p
(
)
AS
[i]--定义变量[/i]
vs_msg VARCHAR2(4000); --错误信息变量
-- 定义游标
CURSOR name_L IS
SELECT ID as ID, count - proccess as value
FROM table_name;
BEGIN
[i] -- 向表中增加一列[/i]
alert
[i] -- 遍历游标更新插入列的值[/i]
FOR rec IN name_L LOOP
UPDATE table_name t
SET REJECT_CONDITION = rec.value
WHERE t.ID = rec.ID;
END LOOP;
COMMIT;
[i] --错误处理部分[/i]EXCEPTION
WHEN OTHERS THEN
-- vs_msg := 'ERROR';
-- ROLLBACK;
--把当前错误记录进日志表。
vs_msg := 'ERROR';
ROLLBACK;
END name_p;[/color]