Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rPivP-00DfBz-UJ for pgsql-general@arkaria.postgresql.org; Tue, 16 Jan 2024 12:52:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rPivO-003k5N-Uk for pgsql-general@arkaria.postgresql.org; Tue, 16 Jan 2024 12:52:14 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rPiMA-003YWk-4N for pgsql-general@lists.postgresql.org; Tue, 16 Jan 2024 12:15:50 +0000 Received: from lvps91-250-99-172.dedicated.hosteurope.de ([91.250.99.172]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rPiM7-00270Q-Fc for pgsql-general@lists.postgresql.org; Tue, 16 Jan 2024 12:15:49 +0000 Received: from HAPPIX (bry-it.net [37.24.105.49]) by lvps91-250-99-172.dedicated.hosteurope.de (Postfix) with ESMTPSA id A08B9FA92D for ; Tue, 16 Jan 2024 13:15:43 +0100 (CET) From: "Rossana Ocampos" To: Subject: Nested-Internal Functions Date: Tue, 16 Jan 2024 13:15:43 +0100 Message-ID: <00d201da4875$ba6c8aa0$2f459fe0$@bry-it.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_00D3_01DA487E.1C33B1C0" X-Mailer: Microsoft Outlook 14.0 Thread-Index: AdpIdauD3QAaKPKoTeOZ+1xey2D+og== Content-Language: de List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multipart message in MIME format. ------=_NextPart_000_00D3_01DA487E.1C33B1C0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 ------=_NextPart_000_00D3_01DA487E.1C33B1C0 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

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:=3D 10;

        RAISE NOTICE = 'Internal Variable: %', internal_variable;

    = END;

    $$ LANGUAGE = plpgsql;

BEGIN

    -- External = function code

    external_variable:=3D = 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 =

------=_NextPart_000_00D3_01DA487E.1C33B1C0--