Files
sql_advanced/lab2-9/task1.sql
T
Vitalii Litvinchuk 6deed0469a first commit
2026-05-04 23:15:09 +03:00

19 lines
705 B
SQL
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#####################################################
###################### Task 1: ##################
1. Створіть SQL-функцію, яка виведе значення вартості (Cost) для угоди,
номер якої вкаже користувач при виклику фукнції.
2. Викличте функцію, використавши в якості вхідного параметра OrderID = 5.
USE Lucky_Shrub;
create function CalculateCost(order_id int)
returns int DETERMINISTIC
begin
declare v_cost int;
select Cost into v_cost from Orders where OrderID = order_id;
return v_cost;
end
set @OrderID = 8;
select CalculateCost (@OrderID);