вот где грабли:
SELECT
dh.ID AS ID, dh.createdat, dh.LOCATION, dh.basedoctypeandid,
dh.docstate, dh.pricetype, dh.execdate, dh.labelsprinted, dh.execif
FROM supermag.svdocumentsac dh
WHERE dh.doctype = 'AC'
AND dh.createdat = TO_DATE ('20081013', 'YYYYMMDD')
AND dh.docstate = 2
AND dh.LOCATION = 12
AND (dh.LOCATION IN (SELECT ID
FROM supermag.svgrantedviewdocslocs))