From: Rossana Ocampos <rocampos@bry-it.com>
To: pgsql-general@lists.postgresql.org
Subject: Nested-Internal Functions
Date: Tue, 16 Jan 2024 13:15:43 +0100
Message-ID: <00d201da4875$ba6c8aa0$2f459fe0$@bry-it.com> (raw)
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: rocampos@bry-it.com
Subject: Re: Nested-Internal Functions
In-Reply-To: <00d201da4875$ba6c8aa0$2f459fe0$@bry-it.com>
References: <00d201da4875$ba6c8aa0$2f459fe0$@bry-it.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox