Re: Calling PL functions with named parameters

From: Andreas Pflug <pgadmin(at)pse-consulting(dot)de>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: David Fetter <david(at)fetter(dot)org>, PG Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Calling PL functions with named parameters
Date: 2004-08-14 17:37:18
Message-ID: 411E4DCE.2050006@pse-consulting.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tom Lane wrote:
> David Fetter <david(at)fetter(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message ohp 2004-08-14 18:34:04 8.0beta1 with unixware
Previous Message Tom Lane 2004-08-14 16:48:30 Re: 7.4 backpatches