Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.tools -> Re: Looping in SQL
> I want to keep trying to alter a table until it is successful. If the alter
> table command
> is not successful, then try the alter command again. If it is not successul
> then do the
> next SQL command. I need to somehow check the SQL error code for alter
> command
> if it's OK or not. Can somebody tell me how to do this in SQL ??
Try this construction
BEGIN
ALTER TABLE
EXCEPTION
WHEN OTHERS THEN
ALTER TABLE
END;
And just nest this block inside your code block.
This way any failure, no matter what it is will trigger a second attempt at the alter table.
Though I'm not quite sure why a second will succeed if the first one failed.
Daniel A. Morgan Received on Sat Mar 24 2001 - 09:06:28 CST
![]() |
![]() |