Advertisement
ryanarnold

Untitled

Jul 21st, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. DECLARE
  2. row_exists NUMBER;
  3. BEGIN
  4.  
  5. row_exists := -1;
  6.  
  7. SELECT count(code_w_prefix)
  8. INTO row_exists
  9. FROM hv_user.cmd_cpt_form_v
  10. WHERE code_w_prefix = :P15_CODE_W_PREFIX
  11. AND insurance_type = :P15_INSURANCE_TYPE;
  12.  
  13. IF row_exists >= 1 THEN
  14. UPDATE hv_user.cmd_cpt_form
  15. SET cpt_code = :P15_CPT_CODE,
  16. cpt_type_update = :P15_CPT_TYPE
  17. WHERE code_w_prefix = :P15_CODE_W_PREFIX
  18. AND insurance_type = :P15_INSURANCE_TYPE;
  19. RETURN;
  20. ELSE
  21. INSERT INTO hv_user.cmd_cpt_form
  22. (code_w_prefix, cpt_code, cpt_type_update, insurance_type, labgen_test_code, labgen_test_name, source_clinic, test_type)
  23. SELECT
  24. code_w_prefix,
  25. :P15_CPT_CODE,
  26. row_exists,--:P15_CPT_TYPE,
  27. :P15_INSURANCE_TYPE,
  28. labgen_test_code,
  29. labgen_test_name,
  30. source_clinic,
  31. test_type
  32. FROM hv_user.cmd_cpt_form_v
  33. WHERE code_w_prefix = :P15_CODE_W_PREFIX
  34. AND insurance_type = 'DEFAULT';
  35. RETURN;
  36. END IF;
  37.  
  38. END;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement