急求!怎么建立oracle存储过程(实例)
createPROCEDUREst_receipt@sheetidchar(16)ASBEGINinsertintoreceiptselect*fromreceipt0w...
create PROCEDURE st_receipt
@sheetid char(16)
AS
BEGIN
insert into receipt select * from receipt0 wheresheetid=@sheetid --将 receipt0表中数据插入 receipt
update receipt set Flag=100 wheresheetid=@sheetid --更新receipt表中Flag值
insert into ReceiptItem select * from ReceiptItem0 where sheetid=@sheetid
delete from ReceiptItem0 where sheetid=@sheetid --删除ReceiptItem0表数据
delete from receipt0 where sheetid=@sheetid --删除 receipt0表数据
end
exec st_receipt @sheetid='ys141128'
这个是sql里的一个存储过程,放到oracle里该怎么写?在线等,急求! 展开
@sheetid char(16)
AS
BEGIN
insert into receipt select * from receipt0 wheresheetid=@sheetid --将 receipt0表中数据插入 receipt
update receipt set Flag=100 wheresheetid=@sheetid --更新receipt表中Flag值
insert into ReceiptItem select * from ReceiptItem0 where sheetid=@sheetid
delete from ReceiptItem0 where sheetid=@sheetid --删除ReceiptItem0表数据
delete from receipt0 where sheetid=@sheetid --删除 receipt0表数据
end
exec st_receipt @sheetid='ys141128'
这个是sql里的一个存储过程,放到oracle里该怎么写?在线等,急求! 展开
2个回答
展开全部
--创建存储过程 IN_SHEETID 为输入参数
CREATE OR REPLACE PROCEDURE ST_RECEIPT(IN_SHEETID VARCHAR2) IS
BEGIN
--将 receipt0表中数据插入 receipt
INSERT INTO RECEIPT
SELECT * FROM RECEIPT0 WHERE SHEETID = IN_SHEETID;
--更新receipt表中Flag值
UPDATE RECEIPT SET FLAG = 100 WHERE SHEETID = IN_SHEETID;
--
INSERT INTO RECEIPTITEM
SELECT * FROM RECEIPTITEM0 WHERE SHEETID = IN_SHEETID;
--删除ReceiptItem0表数据
DELETE FROM RECEIPTITEM0 WHERE SHEETID = IN_SHEETID;
--删除 receipt0表数据
DELETE FROM RECEIPT0 WHERE SHEETID = IN_SHEETID;
END;
--调用存储过程
BEGIN
ST_RECEIPT('ys141128');
END;
--或者
EXEC ST_RECEIPT('ys141128');
2014-11-28 · 知道合伙人软件行家
renfengjun1986
知道合伙人软件行家
向TA提问 私信TA
知道合伙人软件行家
采纳数:925
获赞数:1553
中国地质调查局特聘数据库专家 CSDN博客专家 百度知道数据库行家 炼数成金版主 想了解更多请关注我的博客:
向TA提问 私信TA
关注
展开全部
create or replace PROCEDURE st_receipt(p_sheetid varchar2(16))
AS
BEGIN
insert into receipt select * from receipt0 where sheetid=p_sheetid ; --将 receipt0表中数据插入 receipt
update receipt set Flag=100 wheresheetid=p_sheetid; --更新receipt表中Flag值
insert into ReceiptItem select * from ReceiptItem0 where sheetid=p_sheetid ;
delete from ReceiptItem0 where sheetid=p_sheetid ;--删除ReceiptItem0表数据
delete from receipt0 where sheetid=p_sheetid ; --删除 receipt0表数据
end ;
exec st_receipt('ys141128')
AS
BEGIN
insert into receipt select * from receipt0 where sheetid=p_sheetid ; --将 receipt0表中数据插入 receipt
update receipt set Flag=100 wheresheetid=p_sheetid; --更新receipt表中Flag值
insert into ReceiptItem select * from ReceiptItem0 where sheetid=p_sheetid ;
delete from ReceiptItem0 where sheetid=p_sheetid ;--删除ReceiptItem0表数据
delete from receipt0 where sheetid=p_sheetid ; --删除 receipt0表数据
end ;
exec st_receipt('ys141128')
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |