I need to eliminate the posted record if I have both Posted and Adjusted for same project task
That sort of logic can usually be done in a query with just a NOT EXISTS expression.
So the query would have something like;
SELECT some stuff
FROM some timesheet tables TS, TE, AS
WHERE
AND NOT EXISTS ( SELECT 1 FROM prtimesheet TS1, prtimentry TE1, prassignment AS1
WHERE AS1.prtaskid = AS.prtaskid /* same task as the outer select*/
AND AS1.PRRESOURCEID= AS.PRRESOURCEID /* same resource as the outer select*/
AND AS1.PRID = TE1.PRASSIGNMENTID
AND TE1.PRTIMESHEETID = TS1.PRID
AND TS1.PRTIMEPERIODID = TS.PRTIMEPERIODID /* same time period as the outer select */
AND TS1.PRRESOURCEID= TS.PRRESOURCEID /* same resource as the outer select */
AND TS1.PRID != TS.PRID /* not the same timesheet as the outer select */
AND TS1.PRSTATUS = 4 ) /* is posted */