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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Delete a record in a table

Re: Delete a record in a table

From: Kenneth C Stahl <BluesSax_at_Unforgettable.com>
Date: Wed, 25 Aug 1999 15:56:28 -0400
Message-ID: <37C44A6B.BA1B34CF@Unforgettable.com>


KRM wrote:

> Hello.
>
> I am trying to delete a record in a table in Reports 2.5. I am trying
> to use a cursor to do so. I am trying to use the:
> DELETE <table_name> WHERE CURRENT OF <cursor_name>
>
> I am running into a problem. I have found in two books that I should be
> declaring the cursor to be FOR UPDATE OF..., however, the examples the
> books give list column names, not table names. I need to be able to
> update all the columns, as I will be deleting an entire row. Also, I
> am trying to use the DELETE statement within a loop of the cursor. Can
> someone please give me an example of the syntax? I really appreciate
> it.

Would you believe that there is actually a trick to this?

When you declare something like:

cursor xyz is
select col1, col2
from mytable
for update of col1;

You get a row-level lock on whatever the current row is. You can then issue a

delete where current of xyz;

to delete the row.

Actually the list of columns in the 'for update' clause is more for documentation than anything else. The list of columns doesn't even really need to be there. I could have just as easily written:

cursor xyz is
select col1, col2
from mytable
for update;

and it would have been correct except in a very few esoteric instances.

Ken Received on Wed Aug 25 1999 - 14:56:28 CDT

Original text of this message

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