日期:2014-05-17 浏览次数:20715 次
DECLARE I INTEGER; BEGIN FOR I IN 997 .. 1002 LOOP IF LENGTH(I) < 3 THEN INSERT INTO ROOM (NUM) VALUES ('1F' || LPAD(I, 3, '0')); ELSE INSERT INTO ROOM (NUM) VALUES ('1F' || TO_CHAR(I)); END IF; END LOOP; END; /
------解决方案--------------------
INSERT INTO room (num) select '1F'||reverse(substr(reverse('000' || rownum), 1, 4)) as num from system.help t1, system.help t2 where rownum <= 1500
------解决方案--------------------
DECLARE
I INTEGER:=1;
BEGIN
LOOP
INSERT INTO ROOM (NUM) VALUES ('1F' || LPAD(I, decode(length(to_char(i)),4,4,3), '0'));
exit when i=1500;
i:=i+1
END LOOP;
END;