Changes between Version 4 and Version 5 of DatabaseProgramming-AdvDb


Ignore:
Timestamp:
06/07/26 15:28:15 (9 days ago)
Author:
231175
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DatabaseProgramming-AdvDb

    v4 v5  
    1919        e_id bigint;
    2020    begin
    21         -- Validate rating first, before any DB work
    22         if new_rating < 1 or new_rating > 5 then
    23             raise exception 'Rating must be between 1 and 5, got %', new_rating
    24                 using errcode = 'CHECK_VIOLATION';
    25         end if;
    26 
    2721
    2822        select e.id into e_id
     
    3832                using errcode = 'NO_DATA_FOUND';
    3933        end if;
    40 
    41         -- Validate there's no review for that enrollment
    42         if exists(select 1 from review rv where rv.enrollment_id = e_id) then
    43             raise exception 'Review already submitted for enrollment %', e_id
    44                 using errcode = 'UNIQUE_VIOLATION';
    45         end if;
    46 
    4734
    4835        insert into review (rating, comment, date, enrollment_id)