MOVED mysql/person_get_company.sql to mysql/core_person_get_company.sql
authorAlan Knowles <alan@roojs.com>
Tue, 11 Oct 2016 03:07:17 +0000 (11:07 +0800)
committerAlan Knowles <alan@roojs.com>
Tue, 11 Oct 2016 03:07:17 +0000 (11:07 +0800)
mysql/core_person_get_company.sql [new file with mode: 0644]

diff --git a/mysql/core_person_get_company.sql b/mysql/core_person_get_company.sql
new file mode 100644 (file)
index 0000000..a5dc09e
--- /dev/null
@@ -0,0 +1,15 @@
+
+DROP FUNCTION IF EXISTS person_get_company;
+
+DELIMITER $$
+CREATE FUNCTION person_get_company(  
+       in_id INT(11)
+    )  RETURNS INT(11) DETERMINISTIC
+    BEGIN
+        
+        DECLARE v_id INT(11);
+        SET v_id = 0;
+        SELECT company_id INTO v_id FROM Person WHERE id  = in_id LIMIT 1;
+        RETURN v_id;
+    END $$
+DELIMITER ;