Merge pull request #8645 from mrehkopf/plpgsql_fix

Sakila/PostgreSQL: Replace nonexisting IF with CASE
This commit is contained in:
Lukas Eder 2019-05-17 14:52:01 +02:00 committed by GitHub
commit a452eba624
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -684,8 +684,9 @@ BEGIN
AND rental.rental_date <= p_effective_date
AND rental.customer_id = p_customer_id;
SELECT COALESCE(SUM(IF((rental.return_date - rental.rental_date) > (film.rental_duration * '1 day'::interval),
((rental.return_date - rental.rental_date) - (film.rental_duration * '1 day'::interval)),0)),0) INTO v_overfees
SELECT COALESCE(SUM(CASE WHEN (rental.return_date - rental.rental_date) > (film.rental_duration * '1 day'::interval)
THEN EXTRACT(DAY FROM (rental.return_date - rental.rental_date) - (film.rental_duration * '1 day'::interval))::integer
ELSE 0 END),0) INTO v_overfees
FROM rental, inventory, film
WHERE film.film_id = inventory.film_id
AND inventory.inventory_id = rental.inventory_id