日期:2014-05-16  浏览次数:20739 次

Oracle 批量给某一列循环加数例如从1加到100
DECLARE
???????code number(8) := 1;
???????str_old varchar(5) := '1';
???????str_new varchar(5) := '';
???????data_id varchar(50) := '';
BEGIN
?FOR code IN 1..2234 LOOP?? --从00001循环插入到02234
??
???str_old := '' || code;
???str_new := '';
???--取出每条数据的主键ID
???select id into data_id from (
??????????select id, shortname_code, rownum rm from t_system_org
???) v where v.rm = code;
???--判断字符长度,设定str_new的值
???IF length(str_old) = 1 THEN
?????str_new := '0000' || str_old;
???ELSIF length(str_old) = 2 THEN
?????str_new := '000' || str_old;
???ELSIF length(str_old) = 3 THEN