troubleshooting

Can UDF have a default value for a parameter?

Matan is asking about setting default values for parameters in UDFs and how it can be achieved in the current system.

Ma

Matan Perelmuter

Asked on Aug 03, 2023

  • Yes, UDFs can have default values for parameters in some systems.
  • In the current system, a constant value needs to be provided in SQL when calling the function.
  • Matan mentioned using a constant default value for now but aims to make the UDF more generic for future use.

Example in PostgreSQL:

CREATE FUNCTION gcd(int, int, int DEFAULT 0)

This syntax allows setting a default value for the third parameter in the UDF.

Aug 06, 2023Edited by