Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

default value for parameters 1

Status
Not open for further replies.

thedumbkid

Programmer
May 13, 2003
9
0
0
US
Hi people, I am doing database migration from MS SQL Server to PostgreSQL. I need to know whether parameters can have default values?

In ms sql server, you can assign default values to your parameters. This feature allows you to call the stored procedure without giving parameters that have default values. If parameters are not given, then default values are assume.

I guess this is possible because in SQL Server you can't create stored procedures with the same name, but pgsql allows overloading of functions.

I just want to know a definite answer whether this is possible or not.

thanks a lot! :)
 
as I can see NO, but with overloading you can get the same effect

CREATE FUNCTION xxxx (int4, int4) RETURNS bool AS '
SELECT $1 > $2;
'
LANGUAGE 'sql' IMMUTABLE STRICT;

CREATE FUNCTION xxxx (int4) RETURNS bool AS '
SELECT xxxx($1, 5);
'
LANGUAGE 'sql' IMMUTABLE STRICT;

CREATE FUNCTION xxxx () RETURNS bool AS '
SELECT xxxx(4, 5);
'
LANGUAGE 'sql' IMMUTABLE STRICT;

and some more combinations you can do

and thus only the real function can be written in language plpgsql for example which is slower, and you can assign different options for the diferent function IMMUTABLE, STABLE etc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top