Re: named parameters in SQL functions - Mailing list pgsql-hackers

From Greg Stark
Subject Re: named parameters in SQL functions
Date
Msg-id 407d949e0911151019t4dbbdb48uea26bd064d342ad7@mail.gmail.com
Whole thread Raw
In response to Re: named parameters in SQL functions  (Andrew Chernow <ac@esilo.com>)
Responses Re: named parameters in SQL functions
List pgsql-hackers
On Sun, Nov 15, 2009 at 5:49 PM, Andrew Chernow <ac@esilo.com> wrote:
> Andrew Dunstan wrote:
>>
>> At Tom's suggestion I am looking at allowing use of parameter names in SQL
>> functions instead of requiring use of $1 etc. That raises the question of
>> how we would disambiguate a parameter name from a column name. Essentially,
>> ISTM, we could use some special marker such as @ (c.f. SQL Server) or :
>> (c.f. ecpg) or else we could have some rule that says which name takes
>> precedence. I think I prefer a special marker, other things being equal. Is
>> there a standard on this?
>>
>
> I like the special marker idea.  A '$' would be nice because its already in
> use for similar purposes, but I think that would lead to ambiguity with
> dollar quoting.

I think that would be a big break with everything else and very
non-sql-ish. We don't use these in plpgsql and we don't use them
anywhere else in sql.

Moreover you would still have conflicts possible because sql can quote
identifiers so people can have columns named "$foo". You would have a
weird syntactic detail where "$foo" would mean something different
than $foo even though they're both valid identifiers.

I'm not sure it wouldn't conflict with some drivers either. DBI uses
:foo and ? but I have a vague recollection some drivers did use $foo.

--
greg


pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: named parameters in SQL functions
Next
From: Joachim Wieland
Date:
Subject: Listen / Notify - what to do when the queue is full