Link to home
Start Free TrialLog in
Avatar of sammeras
sammeras

asked on

Different rows result between SELECT and UPDATE statments.

Hello,
I have strange behavior with select and update statment.

WHen i run the update statment:

::SEE UPDATE SCRIPT::

If i run the select statment...with the same condetion and values i got 81 rows:

::SEE SELECT SCRIPT::


Why i got different results ?
WHere is the problem? and how can resolve it?



Thanks.
Sam.
--UPDATE SCRIPT 
UPDATE end_camp_accounts tt SET 
    tt.LAST_ACTION_CODE = 6,
    tt.last_action_date=sysdate+1,
    tt.last_action_user='J83'
WHERE  tt.last_action_code NOT IN (6,0,4)
AND tt.end_date <> trunc(sysdate+1)
AND (
    end_camp_acc_is_active(tt.record_id) = 0
    OR
    end_camp_acc_is_hasava(tt.record_id) = 1
    OR
    end_camp_want_disconnect(tt.record_id)=1
    OR
    end_camp_want_hasava(tt.record_id)=1
);
 
2462 rows updateed.
 
-- ####################################
 
-- SELECT SCRIPT
SELECT 
    record_id 
FROM end_camp_accounts tt
WHERE  tt.last_action_code NOT IN (6,0,4)
AND tt.end_date <> trunc(sysdate+1)
AND (
    end_camp_acc_is_active(tt.record_id) = 0
    OR
    end_camp_acc_is_hasava(tt.record_id) = 1
    OR    
    end_camp_want_disconnect(tt.record_id)=1
    OR
    end_camp_want_hasava(tt.record_id)=1
);
 
81 rows selected.

Open in new window

select.GIF
update.GIF
Avatar of awking00
awking00
Flag of United States of America image

What does the attached query show?
query.txt
Avatar of sammeras
sammeras

ASKER

The query shows 81 results.
ASKER CERTIFIED SOLUTION
Avatar of Sujith
Sujith
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
one chance is that u may have select policies for specific users on that table
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
the proposed answer will not fix the counts.

It is clearly because the table has triggers defined on it. That count mismatch will appear in whatever way the updates are done.