Advertisement
Guest User

Untitled

a guest
Oct 13th, 2015
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. --Skapa backup tabell
  2. create table bu_36377_donorAddDonorType as select * from donor_additional_donor_type;
  3.  
  4. --Verifiering
  5. select * from bu_36377_donorAddDonorType;
  6.  
  7. --Kontroll av antal före uppdatering
  8. select count(*) from donor where not id in (select id from donor_additional_donor_type where donor_type='LAB')
  9. and donor_type='BLOOD'
  10. and (DEREGISTRATION_TYPE is null or DEREGISTRATION_TYPE='MAY_RETURN');
  11.  
  12. -- Insert i tabellen
  13. INSERT INTO DONOR_ADDITIONAL_DONOR_TYPE t (ID, DONOR_TYPE)
  14. select id, 'LAB' as DONOR_TYPE from donor where not id in (select id from donor_additional_donor_type where donor_type='LAB')
  15. and donor_type='BLOOD'
  16. and (DEREGISTRATION_TYPE is null or DEREGISTRATION_TYPE='MAY_RETURN');
  17.  
  18. --Kontroll av antal efter uppdatering och då MÅSTE alltid vara 0 rader
  19. select count(*) from donor where not id in (select id from donor_additional_donor_type where donor_type='LAB')
  20. and donor_type='BLOOD'
  21. and (DEREGISTRATION_TYPE is null or DEREGISTRATION_TYPE='MAY_RETURN');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement