Пример для bat, cmd файла. Если запускать не на сервере, то нужно указать имя БД в CONNECT supermag@DATABASE.
@echo off
set nls_lang=russian_cis.ru8pc866
echo CONNECT supermag > smpostfailpack.sql
echo DELETE FROM smpostfailpack >> smpostfailpack.sql
echo WHERE (vp, uploadtime, packtype, srcloc, enqseq) IN ( >> smpostfailpack.sql
echo SELECT vp, uploadtime, packtype, srcloc, enqseq >> smpostfailpack.sql
echo FROM (SELECT vp, uploadtime, packtype, srcloc, >> smpostfailpack.sql
echo MAX (enqseq) enqseq, COUNT (*) COUNT >> smpostfailpack.sql
echo FROM smpostfailpack >> smpostfailpack.sql
echo GROUP BY vp, uploadtime, packtype, srcloc) >> smpostfailpack.sql
echo WHERE COUNT != 1); >> smpostfailpack.sql
echo COMMIT ; >> smpostfailpack.sql
echo EXIT >> smpostfailpack.sql
sqlplus.exe /nolog @smpostfailpack.sql
del smpostfailpack.sql
pause
exit