Nested-Internal Functions

2024-01-16 Thread Rossana Ocampos
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 



AW: Nested-Internal Functions

2024-01-18 Thread Rossana Ocampos
Effectively I had to create the function externally, I am in the process of 
migrating from Oracle to Postgresql and I have many cases of encapsulated 
functions and transactions.
Thank you very much for the return.
Rossana Ocampos

-Ursprüngliche Nachricht-
Von: Laurenz Albe [mailto:laurenz.a...@cybertec.at] 
Gesendet: Dienstag, 16. Januar 2024 15:42
An: Rossana Ocampos; pgsql-general@lists.postgresql.org
Betreff: Re: Nested-Internal Functions

On Tue, 2024-01-16 at 13:15 +0100, Rossana Ocampos wrote:
> I have a query about creating nested functions in PostgreSQL.

There are no "nested functions" in PostgreSQL.
You'd need to rewrite that to use a proper stand-alone function.

Yours,
Laurenz Albe





CURRENTE_DATE

2024-10-23 Thread Rossana Ocampos
Hello ,

I am new with PostgreSQL and I have a bug. I have created a function that
has an input variable of type date , in case it does not receive value , it
has to assume by default the current date.

I have defined it as follows variable  DATE DEFAULT CURRENT_DATE, but I get
the following error.

 

El error 

ERROR: invalid input syntax for type date: "CURRENT_DATE" LINE 1:
...extsupplydate ('1085018'::bigint, '5278'::bigint, 'CURRENT_D... ^ ERROR:
invalid input syntax for type date: "CURRENT_DATE" SQL status: 22007
Characters: 78

 

Please could you help me, thank you very much.

Rossana