刚刚接触Oracle 今天也是刚开始写了一个非常简单的存储过程,并执行它
将下面的代码拷贝到PL/SQL Developer下面的空白程序窗口
CREATE OR REPLACE PROCEDURE "POC"."BAK_QUESTION" (newid IN NUMBER,oldid IN NUMBER)
AS
BEGIN
INSERT INTO question_old
(ID, vid, oldid, DIMENSIONCODE, DISPLAYNO, QUESTTYPE, ENNAME, CNNAME, CNNAMEAFFIX, QUESTREFSCOREMIN, QUESTREFSCOREMAX, CREATE_TIME, END_TIME, TIPINFO, QUESTDEFSCORE, QUESTDEFVAL, COND)
SELECT BASE_SEQ.NEXTVAL,newid,ID, DIMENSIONCODE, DISPLAYNO, QUESTTYPE, ENNAME, CNNAME, CNNAMEAFFIX, QUESTREFSCOREMIN, QUESTREFSCOREMAX, CREATE_TIME, END_TIME, TIPINFO, QUESTDEFSCORE, QUESTDEFVAL, COND
FROM question
WHERE DIMENSIONCODE = oldid;
END;
执行它,然后看该用户下面的这个Procedure上面是否有小红叉,如果有就代表有问题,需要将该存储过程删除掉,直至没有问题成功创建,然后使用下面命令执行存储过程:
BEGIN
BAK_QUESTION(5,7);
END;
然后就可以看看数据有没有塞到question_old这个表里面!
附procedure, function, trigger, package的区别:
trigger: you
can use trigger if you want to do others something(format, field check,
caculation etc.) when you insert, update or delete on the table. it
binds with table.
procedure, function can be exist standalone.
function always must retun a value. procedure needn´t.
you can call procedure or function in trigger. you,however, cann´t call trigger in procedure and function.
package里面可能用到多个procedure, 或者function完成一个比较复杂的功能!
阅读(3959) | 评论(0) | 转发(0) |