哪位大G帮忙看看啊..在SQL SERVER 的存储过程改成oracle中能运行的.改来改去还是报错...哭死了..哪位GG帮忙看看正确的改法啊.不甚感激呀....SQL SERVER的存储过程是:
CREATE Procedure GetChildID
@CustomerNo varchar(20)
as
set nocount on
if @CustomerNo<>''
begin
declare @T_ID int,@T_No varchar(20),@T_LAB int
declare My_Cursor cursor local for select ID,CustomerNo,ParentID from Customer where ParentID=(select ID from customer where CustomerNo=@CustomerNo)
open My_Cursor
fetch next from My_Cursor into @T_ID,@T_No,@T_LAB --游标指向第一条记录
while @@fetch_status=0 begin
insert into temptable(ID ,ParentID) values(@T_ID,@T_LAB)
Execute GetChildID @T_No
fetch next from My_Cursor into @T_ID,@T_No,@T_LAB
end
close My_Cursor
deallocate My_Cursor
end
set nocount off
GO
------解决方案--------------------
- SQL code
CREATE OR REPLACE PROCEDURE GETCHILDID(CUSTOMERNO VARCHAR2) IS T_ID INT; T_NO VARCHAR2(20); T_LAB INT; CURSOR MY_CURSOR(X VARCHAR2) IS SELECT ID, CUSTOMERNO, PARENTID FROM CUSTOMER WHERE PARENTID = (SELECT ID FROM CUSTOMER WHERE CUSTOMERNO = X);BEGIN IF CUSTOMERNO IS NOT NULL THEN OPEN MY_CURSOR(CUSTOMERNO); LOOP FETCH MY_CURSOR INTO T_ID, T_NO, T_LAB; EXIT WHEN MY_CURSOR%NOTFOUND; INSERT INTO TEMPTABLE (ID, PARENTID) VALUES (T_ID, T_LAB); END LOOP; END IF; CLOSE MY_CURSOR;END;/
代码迷推荐解决方案:oracle存储过程,http://www.daimami.com/search?q=177537