Changes between Version 1 and Version 2 of UseCase11


Ignore:
Timestamp:
01/25/26 19:15:24 (2 weeks ago)
Author:
231035
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • UseCase11

    v1 v2  
    88SELECT clinic_id, name, city, address
    99FROM vet_clinics
    10 WHERE clinic_id = $1;
     10WHERE name = 'Happy Paws Clinic';
    1111}}}
    12122. Clicks the "Leave review" button.
     
    1515BEGIN;
    1616
    17 INSERT INTO reviews (reviewer_id, rating, comment, created_at)
    18 VALUES ($1, $2, $3, NOW())
    19 RETURNING review_id;
    20 
     17WITH new_review AS (
     18  INSERT INTO reviews (reviewer_id, rating, comment, created_at)
     19  VALUES (
     20    (SELECT user_id FROM users WHERE username = 'client.viktor'),
     21    5,
     22    'Excellent clinic, very professional staff.',
     23    NOW()
     24  )
     25  RETURNING review_id
     26)
    2127INSERT INTO clinic_reviews (review_id, target_clinic_id)
    22 VALUES ($4, $5);
     28SELECT
     29  nr.review_id,
     30  (SELECT clinic_id FROM vet_clinics WHERE name = 'Happy Paws Clinic')
     31FROM new_review nr;
    2332
    2433COMMIT;