Declare local variable : Local Variable « Postgre SQL « PostgreSQL






Declare local variable

postgres=# CREATE FUNCTION "add_two_loop" (integer,integer) RETURNS integer AS '
postgres'#   DECLARE
postgres'#      -- Declare aliases for function arguments.
postgres'#     low_number ALIAS FOR $1;
postgres'#     high_number ALIAS FOR $2;
postgres'#
postgres'#      -- Declare a variable to hold the result.
postgres'#
postgres'#     result INTEGER = 0;
postgres'#   BEGIN
postgres'#     WHILE result != high_number LOOP
postgres'#       result := result + 1;
postgres'#     END LOOP;
postgres'#
postgres'#     RETURN result;
postgres'#   END;
postgres'# ' LANGUAGE 'plpgsql';
CREATE FUNCTION
postgres=#
postgres=# select add_two_loop(10,10);
 add_two_loop
--------------
           10
(1 row)

postgres=#
postgres=#

           
       








Related examples in the same category