Notices
Computer & Technology Related Post here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.

Oracle experts

Thread Tools
 
Search this Thread
 
Old 12 May 2009, 08:39 AM
  #1  
TopBanana
Scooby Regular
Thread Starter
 
TopBanana's Avatar
 
Join Date: Jan 2001
Posts: 9,781
Likes: 0
Received 0 Likes on 0 Posts
Default Oracle experts

I need to return a set of rows in a procedure, and then delete them in that same procedure. Is there a neat way of doing this without temp tables? Something like an in-memory cursor maybe?
Old 12 May 2009, 10:44 PM
  #2  
tarmac terror
Scooby Regular
iTrader: (2)
 
tarmac terror's Avatar
 
Join Date: May 2005
Location: Northern Ireland
Posts: 2,498
Received 0 Likes on 0 Posts
Default

Are you wanting to move data or are you working with queued data?
Please test this first - I haven't done much work in Oracle in years I think it could be as simple as this;

DELETE FROM <table> WHERE <conditions> RETURNING <column1>, <column2> INTO <array1>, <array2>

The hassle is that if you have 50 columns per record you have to have one array for each of them.

Would this also work using the cursor method that your suggested.

DECLARE CURSOR c_updates
IS
SELECT * FROM table1 t1
LEFT JOIN table2 t2 ON t1.field = t2.field
WHERE t2.field IS NULL
FOR UPDATE OF t1.field;
a_record c_updates%ROWTYPE;

BEGIN
OPEN c_updates;
LOOP
FETCH c_updates INTO a_record;
EXIT WHEN c_updates%NOTFOUND;
DELETE FROM table1
WHERE CURRENT OF c_updates;
END LOOP;
CLOSE c_updates;
END;

If I have just posted a pile of poo apologies - like I say, out of Oracle years ages ago, if indeed I was ever really into it.
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
roysc
ScoobyNet General
2
16 September 2015 09:10 AM
The Joshua Tree
Computer & Technology Related
18
11 September 2015 09:24 PM
mega_stream
Non Scooby Related
2
09 August 2001 07:51 PM
stan
Non Scooby Related
5
20 September 2000 02:07 PM



Quick Reply: Oracle experts



All times are GMT +1. The time now is 05:58 AM.