From dce62490818170b6479dfe08a28aae4bcdf7cc2d Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Wed, 13 Jan 2021 15:59:57 -0500 Subject: [PATCH] Doc, more or less: uncomment tutorial example that was fixed long ago. Reverts a portion of commit 344190b7e. Apparently, back in the twentieth century we had some issues with multi-statement SQL functions, but they've worked fine for a long time. Daniel Westermann Discussion: https://postgr.es/m/GVAP278MB04242DCBF5E31F528D53FA18D2A90@GVAP278MB0424.CHEP278.PROD.OUTLOOK.COM --- src/tutorial/funcs.source | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/tutorial/funcs.source b/src/tutorial/funcs.source index 7bbda599a6..542b5c81ec 100644 --- a/src/tutorial/funcs.source +++ b/src/tutorial/funcs.source @@ -99,24 +99,21 @@ SELECT name(high_pay()) AS overpaid; ----------------------------- -- Creating SQL Functions with multiple SQL statements -- you can also create functions that do more than just a SELECT. --- --- 14MAR99 Clark Evans: Does not quite work, commented out for now. --- ----------------------------- -- you may have noticed that Andy has a negative salary. We'll create a -- function that removes employees with negative salaries. --- --- SELECT * FROM EMP; --- --- CREATE FUNCTION clean_EMP () RETURNS integer --- AS 'DELETE FROM EMP WHERE EMP.salary <= 0; --- SELECT 1 AS ignore_this' --- LANGUAGE SQL; --- --- SELECT clean_EMP(); --- --- SELECT * FROM EMP; + +SELECT * FROM EMP; + +CREATE FUNCTION clean_EMP () RETURNS integer + AS 'DELETE FROM EMP WHERE EMP.salary <= 0; + SELECT 1 AS ignore_this' + LANGUAGE SQL; + +SELECT clean_EMP(); + +SELECT * FROM EMP; -----------------------------