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: Looping in SQL

Re: Looping in SQL

From: Daniel A. Morgan <dmorgan_at_exesolutions.com>
Date: Sat, 24 Mar 2001 07:06:28 -0800
Message-ID: <3ABCB7F4.E6140BB0@exesolutions.com>

> 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

Original text of this message

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