Explorar o código

Create a function returning an int of a chosen tuple

DricomDragon %!s(int64=5) %!d(string=hai) anos
pai
achega
3ac6b0df0e
Modificáronse 1 ficheiros con 11 adicións e 0 borrados
  1. 11 0
      SQL/plpgsql/create_biggest_ordered_quantity.sql

+ 11 - 0
SQL/plpgsql/create_biggest_ordered_quantity.sql

@@ -0,0 +1,11 @@
+CREATE OR REPLACE FUNCTION biggest_ordered_quantity() RETURNS INTEGER AS 
+$$
+DECLARE
+    ans INTEGER;
+BEGIN
+    SELECT ori_quantity FROM OrderedItem WHERE ori_id = 1 INTO ans;
+
+    RETURN ans;
+END;
+$$
+LANGUAGE plpgsql;