title: PL/SQL Procedure to Delete Specific Rows
body: <p>Trying to create a stored procedure to delete all goods supplied by a distributor (x) as well as the references to the goods in my <code>LINE</code> table. My problem is there are 3 tables in total. So i need to delete the references from my <code>LINE</code> table first before deleting the items in <code>GOODS</code> table and I can't seem to figure it out correctly. I feel like I have it just need some help with a few syntax errors.</p>
  
  <pre><code>CREATE OR REPLACE PROCEDURE PRC_DeleteProd(x IN INTEGER)
  AS
      v_dcode    distributor.d_code%type;
      v_gcode    goods.g_code%type;
      v_gcode2   line.g_code%type;
  
   CURSOR v_delete_cursor IS
     SELECT goods.g_code, line.g_code , d_code
       FROM distributor
       JOIN goods ON (distributor.d_code = goods.g_code)
       JOIN line ON (goods.g_code = line.g_code);
  
  BEGIN
  
    OPEN v_delete_cursor;
  
    LOOP
      FETCH v_delete_cursor INTO v_dcode, v_gcode, v_gcode2;
      EXIT WHEN v_cus_cursor%NOTFOUND;
  
      IF x = v_dcode THEN
        DELETE FROM line WHERE v_gcode2 = x;
  
        DELETE FROM goods WHERE v_gcode = x;
      END IF;
    END LOOP;
  END;
  /
  </code></pre>