Re: Calling PL functions with named parameters - Mailing list pgsql-hackers

From Andreas Pflug
Subject Re: Calling PL functions with named parameters
Date
Msg-id 411E4DCE.2050006@pse-consulting.de
Whole thread Raw
In response to Re: Calling PL functions with named parameters  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Tom Lane wrote:
> David Fetter <david@fetter.org> writes:
> 
>>CREATE OR REPLACE FUNCTION foo_func(name TEXT, val INTEGER) AS ...
> 
> 
>>SELECT foo_func(val AS 23, name AS 'Name goes here');
> 
> 
> I don't think that syntax will work.  You could possibly do it the other
> way round:
> 
> SELECT foo_func(23 AS val, 'Name goes here' AS name);
> 
> which would have some commonality with SELECT's column-labeling syntax
> but otherwise seems to have little to recommend it.  Are there any other
> vendors supporting such things in SQL, and if so how do they do it?

MSSQL's syntax for calling named parameters is like this:

CREATE PROCEDURE SampleProcedure @EmployeeIDParam INT,@MaxQuantity INT OUTPUT AS ...

DECLARE @MaxQtyVariable INT
EXEC @rc = SampleProcedure @EmployeeIDParam = 9,@MaxQuantity = @MaxQtyVariable OUTPUT

This is commonly used if a parameter should be left default (and I don't 
like it).

Regards,
Andreas


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: will PITR in 8.0 be usable for "hot spare"/"log shipping" type of replication
Next
From: Tom Lane
Date:
Subject: Re: 7.4 backpatches