From: | "Rossana Ocampos" <rocampos(at)bry-it(dot)com> |
---|---|
To: | <pgsql-general(at)lists(dot)postgresql(dot)org> |
Subject: | Nested-Internal Functions |
Date: | 2024-01-16 12:15:43 |
Message-ID: | 00d201da4875$ba6c8aa0$2f459fe0$@bry-it.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hello ,
I have a query about creating nested functions in PostgreSQL.
I am currently using PostgreSQL 15 and I am trying to create a nested
function with the following structure:
CREATE OR REPLACE FUNCTION external_function ()
RETURNS void AS $$
DECLARE
external_variable;
-- Define the internal function
FUNCTION internal_function ()
RETURNS void AS $$
DECLARE
internal_variable INT;
BEGIN
-- Internal function code
internal_variable:= 10;
RAISE NOTICE 'Internal Variable: %', internal_variable;
END;
$$ LANGUAGE plpgsql;
BEGIN
-- External function code
external_variable:= 5;
RAISE NOTICE 'External variable: %', external_variable;
-- Call internal function
PERFORM internal_function ();
END;
$$ LANGUAGE plpgsql;
However, I get an error, and I can't compile the function.
Thank you very much for your help
Rossana Ocampos
From | Date | Subject | |
---|---|---|---|
Next Message | arun chirappurath | 2024-01-16 12:34:46 | postgres sql assistance |
Previous Message | Matthias Apitz | 2024-01-16 10:24:28 | /usr/local/sisis-pap/pgsql-15.1/bin/postmaster SIGSEGV in podman container on MacOS |