How to get count of records in a delete statement [message #255744] |
Wed, 01 August 2007 11:27 |
aviana
Messages: 106 Registered: July 2007
|
Senior Member |
|
|
Hi,
I am writing a PL/SQL procedure which involves a few delete statements.Each delete will work if a few conditions are satisfied. There is a cursor selecting records and in delete, the table values are also compared with the manipulation of values in the records hold by cursor.
Now I want to get a count of how many records are deleted from the table under each condition?How will I get that?
Thanks a million
|
|
|
|
Re: How to get count of records in a delete statement [message #255942 is a reply to message #255749] |
Thu, 02 August 2007 08:30 |
aviana
Messages: 106 Registered: July 2007
|
Senior Member |
|
|
--Cursor definition
CURSOR c_street_hnr1
IS
SELECT ROWID, house_number_code, street_id, building_nr
FROM alpha_building_no
WHERE (building_nr LIKE '%#_%' ESCAPE '#')
OR (building_nr LIKE '%/%')
OR (building_nr LIKE '%-%');
OPEN c_street_hnr1;
LOOP
FETCH c_street_hnr1
INTO v_str_rowid, v_hnr_sortcode, v_street_id, v_building_nr;
EXIT WHEN c_street_hnr1%NOTFOUND;
--Other codes
IF v_num_seq = '-'
THEN
IF INSTR (var_num_low, '$') = 0 AND INSTR (var_num_high, '$') = 0
THEN
DELETE FROM alpha_building_no
WHERE house_number_code = v_hnr_sortcode
AND street_id = v_street_id
AND DECODE
(INSTR
(TRANSLATE
(Trim_Building_Nr_Parts.trim_building_nr_left
(building_nr),
'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
'$$$$$$$$$$$$$$$$$$$$$$$$$$'
),
'$'
),
0, NVL
(TO_NUMBER
(Trim_Building_Nr_Parts.trim_building_nr_left
(building_nr)
),
0
),
-1
) BETWEEN v_num_low_out AND v_num_high_out
AND DECODE
(INSTR
(TRANSLATE
(Trim_Building_Nr_Parts.trim_building_nr_right
(building_nr),
'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
'$$$$$$$$$$$$$$$$$$$$$$$$$$'
),
'$'
),
0, NVL
(TO_NUMBER
(Trim_Building_Nr_Parts.trim_building_nr_right
(building_nr)
),
0
),
-1
) BETWEEN v_num_low_out AND v_num_high_out
AND ROWID <> v_str_rowid;
--rest of the code for other,conditions closing if,closing cursor etc comes here
There is only 1 delete statement shown here.Similarly there are a number of deletes.I want the total count for all the deletes inside the cursor and be able to write into a table how many deletes happened altogether.Just show me for this one and then I should be able to do it for the rest.
[EDITED by LF - modified [code] tags]
[Updated on: Thu, 02 August 2007 14:53] by Moderator Report message to a moderator
|
|
|
|