Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dmidlo/bb0c278e835e31f17f59f727182ad761 to your computer and use it in GitHub Desktop.
Save dmidlo/bb0c278e835e31f17f59f727182ad761 to your computer and use it in GitHub Desktop.
PLSQL - Function - Increment an Integer
-- Solution 1
CREATE OR REPLACE FUNCTION increment(i integer) RETURNS integer as $$
BEGIN
return i + 1;
END;
$$ LANGUAGE plpgsql;
-- Soluution 2
CREATE FUNCTION increment(i integer) RETURNS integer
AS 'select $1 + 1;'
LANGUAGE sql;
-- Solution 3
CREATE FUNCTION increment (IN age integer, OUT integer)
AS 'SELECT age + 1'
LANGUAGE SQL;
-- Solution 4
CREATE FUNCTION increment(@age INT) {
returns INT as
Begin
return @age + 1;
end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment