BEGIN
  FOR cmd IN (
    SELECT 'UPDATE "' || T.Table_Name || '" SET UUID = SYS_GUID(), ' || Dit.Di000215 || ' = ' || Di.Di000215 CMD_UPDATE_LICENCE
    FROM User_Tables T inner join Dt415 Dt on T.Table_Name = Dt.Di000216
                       inner join Dt412 Di on Dt.Di000265 = Di.Di000239 and Di.Di041035 in ('license','license_id')
                       inner join Dt412 Dit on Dt.Di000265 = Dit.Di000239 and Dit.Di041035 = 'own_lic'
    WHERE T.Table_Name In ('DT345','DT346','DT348','DT396','DT547','DT953','DT820','DT004','DT401','DT439')
    )
  LOOP
    BEGIN
      dbms_output.put_line (cmd.CMD_UPDATE_LICENCE);
      EXECUTE IMMEDIATE cmd.CMD_UPDATE_LICENCE;
    END;
  END LOOP;
END;
