Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.tools -> Re: Help: PL/SQL insert and delete

Re: Help: PL/SQL insert and delete

From: Ed Prochak <ed.prochak_at_magicinterface.com>
Date: Sat, 26 May 2001 04:56:49 GMT
Message-ID: <3B0F62DC.AAB22349@magicinterface.com>

xxx wrote:
>
> We need to develop a PL/SQL of aging an table.
> What I do is
>
> cursor x is select * from table A where polltime < sysdate-1;
> Begin
> FOR y in x LOOP
> insert into table B values (col1 y.col1,col2 y.col2);
> delete from table A where col1=y.col1;
> END LOOP;
> END;
>
> The problem is, sometimes, insert did not finish, while delete still can go
> on, cause loss some data, how can we improve the PL/SQL?
> Thank you for your help.

where are your commits? Do you have any exception handlers in your code? Are you sure you saw data deleted when the insert did not? and the real code has no other code (like IF THEN statements)?

try putting in a COMMIT just after the insert.

An alternative is two loops. first pass does all the inserts. second pass deletes what was copied. Received on Fri May 25 2001 - 23:56:49 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US