oracle菜鸟求翻译!急!!!!!急!!各位大大求告诉!
本帖最后由 xiaozhuoxt 于 2013-11-10 21:43:06 编辑
DECLARE @KMJB int
SET @KMJB=2
WHILE @KMJB<(select max(kmjb)+1 from atbl)
BEGIN
update atbl
set kmqc=(select distinct A.kmqc+'-'+atbl.kmmc from atbl A
WHERE A.dzbh=atbl.dzbh
AND A.kmbm=atbl.sjkmbm
)
WHERE kmjb=@kmjb
set @kmjb=@kmjb+1
end
这是sqlserver中的语句 根据kmjb循环得到kmqc,怎么在oracle中编写declare.
------解决方案--------------------DECLARE V_KMJB NUMBER DEFAULT 2,V_NUM NUMBER;
SELECT MAX(KMJB)+1 INTO V_NUM FROM ATBL;
WHILE V_KMJB<V_NUM LOOP
UPDATE ATBL SET KMQC=(SELECT DISTINCT A.KMQC
------解决方案-------------------- '-'
------解决方案-------------------- ATBL.KMMC FROM ATBL A
WHERE A.DZBH=ATBL.DZBH AND A.KMBM=ATBL.SJKMBM)
WHERE KMJB=V_KMJB
V_KMJB:=VKMJB+1;
END LOOP;
------解决方案--------------------
DECLARE V_KMJB NUMBER DEFAULT 2,V_NUM NUMBER;
BEGIN
SELECT MAX(KMJB)+1 INTO V_NUM FROM ATBL;
WHILE V_KMJB<V_NUM LOOP
UPDATE ATBL SET KMQC=(SELECT DISTINCT A.KMQC
------解决方案--------------------
'-'
------解决方案--------------------
ATBL.KMMC FROM ATBL A
WHERE A.DZBH=ATBL.DZBH AND A.KMBM=ATBL.SJKMBM)
WHERE KMJB=V_KMJB;
V_KMJB:=VKMJB+1;
END LOOP;
END;