Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.tools -> Re: Problems with PL/SQL
Rognvald Bjarne wrote:
>
> Try this:
>
> DECLARE
> a INTEGER;
> b INTEGER;
> CURSOR sel_stmt IS SELECT * FROM table_source;
> sel_val sel_stmt%ROWTYPE;
> BEGIN
> a:=1
> b:=1
> FOR a IN (<series out how many records total you want to insert>) LOOP
> OPEN sel_stmt;
> FETCH sel_stmt INTO sel_val;
> INSERT INTO table_target VALUES (sel_val.<column1>, sel_val.<column2>, etc.)
> IF b = 1000
> THEN GOTO commit_logic
> ELSE GOTO continue_logic
> END IF;
> <<commit_logic>>
> COMMIT;
> b:=1;
> <<continue_logic>>
> a:=a+1
> b:=b+1
> END LOOP;
> CLOSE sel_stmt;
> --commit the last batch
> COMMIT;
> END;
> /
>
> I may have some mistakes in there whipping it out, but the gist is you have
> to deal with the records one at a time within the loop.
>
Same thing that I noted with Klaus's entry - this will probably generate a "snapshot too old"error. Received on Tue Aug 15 2000 - 14:54:54 CDT
![]() |
![]() |