It would be easer if there were some sample data and expected result provided.
Anyway, with the blind guessed sample data like this:
-- S a m p l e D a t a :
Create Table tbl_1 (buck Number(10), sname VarChar2(20), some_col VarChar2(24));
Insert Into tbl_1
Select 101, 'abc', 'some 101' FRom Dual Union All
Select 101, 'def', 'some 101' FRom Dual Union All
Select 101, 'ghi', 'some 101' FRom Dual Union All
--
Select 102, 'abc', 'some 102' FRom Dual Union All
Select 102, 'def', 'some 102' FRom Dual Union All
Select 102, 'ghi', 'some 102' FRom Dual Union All
--
Select 103, 'abc', 'some 103' FRom Dual Union All
Select 103, 'def', 'some 103' FRom Dual Union All
Select 103, 'ghi', 'some 103' FRom Dual Union All
--
--
Select 999, 'jkl', 'some 999' FRom Dual Union All
Select 999, 'mno', 'some 999' FRom Dual Union All
Select 999, 'prs', 'some 999' FRom Dual;
Create Table tbl_2 (sname VarChar2(20), sdiv VarChar2(10), some_other_col VarChar2(12));
Insert Into tbl_2
Select 'abc', 'xyz', 'some a' FRom Dual Union All
Select 'abc', 'tre', 'some tre' FRom Dual Union All
Select 'def', 'vuw', 'some d' FRom Dual Union All
Select 'ghi', 'tre', 'some g' FRom Dual Union All
Select 'jkl', 'pqr', 'some j' FRom Dual;
-- B e f o r e :
Select * From tbl_1 Order By buck, sname;
| BUCK |
SNAME |
SOME_COL |
| 101 |
abc |
some 101 |
| 101 |
def |
some 101 |
| 101 |
ghi |
some 101 |
| 102 |
abc |
some 102 |
| 102 |
def |
some 102 |
| 102 |
ghi |
some 102 |
| 103 |
abc |
some 103 |
| 103 |
def |
some 103 |
| 103 |
ghi |
some 103 |
| 999 |
jkl |
some 999 |
| 999 |
mno |
some 999 |
| 999 |
prs |
some 999 |
If I got it right the rows from the tbl_1 which are in bold letters above should be deleted cause in tbl_2 snames 'abc' and 'ghi' have the sdiv = 'tre'.
Maybe you don't need the procedure at all - try to do it using MERGE.
MERGE INTO tbl_1 t
USING ( select Distinct t1.sname
from tbl_1 t1
inner join tbl_2 t2 ON (t2.sname = t1.sname And t2.sdiv = 'tre')
) x ON(x.sname = t.sname)
WHEN MATCHED THEN
UPDATE SET t.some_col = 'delete this row'
DELETE WHERE t.some_col = 'delete this row';
-- A f t e r :
Select * From tbl_1 Order By buck, sname;
| BUCK |
SNAME |
SOME_COL |
| 101 |
def |
some 101 |
| 102 |
def |
some 102 |
| 103 |
def |
some 103 |
| 999 |
jkl |
some 999 |
| 999 |
mno |
some 999 |
| 999 |
prs |
some 999 |
fiddle
...
OR if you want to delete all rows for buck related to sdiv = 'tre'
MERGE INTO tbl_1 t
USING ( select Distinct t1.buck
from tbl_1 t1
inner join tbl_2 t2 ON (t2.sname = t1.sname And t2.sdiv = 'tre')
) x ON(x.buck = t.buck)
WHEN MATCHED THEN
UPDATE SET t.some_col = 'delete this row'
DELETE WHERE t.some_col = 'delete this row';
-- A f t e r :
Select * From tbl_1 Order By buck, sname;
| BUCK |
SNAME |
SOME_COL |
| 999 |
jkl |
some 999 |
| 999 |
mno |
some 999 |
| 999 |
prs |
some 999 |
fiddle