日期:2014-05-17  浏览次数:20782 次

疯了,oracle中怎么创建存储过程呀??????????
oracle中怎么创建存储过程

------解决方案--------------------
我的异常网推荐解决方案:oracle存储过程,http://www.aiyiweb.com/oracle-develop/177537.html
------解决方案--------------------
--研究明白了这个基本上创建一个存储过程是不成问题了
create or replace package pkg
is
type cur is ref cursor;
procedure bb( a in int,b out varchar2,Rst out cur);
end pkg;
/
create or replace package body pkg
is
procedure bb( a in int,b out varchar2,Rst out cur)
is
begin
b:=a;
open Rst for select * from table1;
end;
end pkg;
------解决方案--------------------
楼主啊,遇到问题自己多琢磨琢磨~
------解决方案--------------------
很简单的,下面有个新增商品的小例子,不过在这之前你得自己建表哦

CREATE OR REPLACE Package body Product
as
/* 新增商品关系类型信息 */
--PRODUCT
PROCEDURE ProductRelationTypeInsert(
v_PKID IN OUT NUMBER ,
v_FULLNAME VARCHAR2,
v_RELATIONANAME VARCHAR2,
v_RELATIONBNAME VARCHAR2,
v_DESCRIPTION VARCHAR2,
v_PARENTID NUMBER,
v_VALID CHAR,
v_LASTMODIFIER NUMBER,
v_LASTMODIFYTIME CHAR,
v_IMPORTTIME CHAR,
v_EXPORTTIME CHAR
)
IS
BEGIN
INSERT INTO TPRODUCTRELATIONTYPE (PKID,FULLNAME,RELATIONANAME,RELATIONBNAME,DESCRIPTION,PARENTID,VALID,LASTMODIFIER,LASTMODIFYTIME,IMPORTTIME,EXPORTTIME)
VALUES (
TPRODUCTRELATIONTYPE_ID.NEXTVAL,
v_FULLNAME,
v_RELATIONANAME,
v_RELATIONBNAME,
v_DESCRIPTION,
v_PARENTID,
v_VALID,
v_LASTMODIFIER ,
TO_CHAR(SYSDATE, 'YYYYMMDDHH24MISS '),
v_IMPORTTIME,
v_EXPORTTIME)
RETURNING PKID INTO v_PKID;
END ProductRelationTypeInsert;
------解决方案--------------------
---------------------例子来了-----------------------------------
create or replace procedure SP_GA_RESULT_SETTING
(
idataid in varchar2,
icoCodeList in varchar2,
iruleCodeList in varchar2,
excepIdS in varchar2, 
beginDate in varchar2, 
endDate in VARCHAR2 
) is

vResSettleSqlStr varchar2(4000);
replaceExcepIds varchar2(4000);
BEGIN
 
replaceExcepIds := replace(excepIdS,',',''',''');
vResSettleSqlStr := 'UPDATE GA_RESULT_LIST LIST 
SET LIST.STATUS = 5, LIST.MODIFY_TIME = SYSDATE, LIST.RESULT_ID = ' || idataid || '
WHERE LIST.UUID IN
(SELECT A.UUID
FROM GA_RESULT_LIST A, GL_VOU_HEAD B
WHERE A.VOU_NO = B.VOU_NO
AND A.VOU_CO_CODE = B.CO_CODE
AND A.VOU_FISCAL = B.FISCAL
AND A.VOU_ACCOUNT_ID = B.ACCOUNT_ID
AND B.VOU_DATE >= TO_DATE(''' || beginDate || ''',''YYYY-MM-DD'')
AND B.VOU_DATE <= TO_DATE(''' || endDate || ''',''YYYY-MM-DD'')';
if icoCodeList <> '*' then
vResSettleSqlStr := vResSettleSqlStr || ' AND B.CO_CODE IN (''' || icoCodeList || ''')';
end if;
if iruleCodeList <> '*' then
vResSettleSqlStr := vResSettleSqlStr || ' AND A.RULE_CODE IN (''' || iruleCodeList || ''')';
end if;
if excepIdS IS NOT NULL then
vResSettleSqlStr := vResSettleSqlStr || ' AND A.RUL