I come from a SQL Server background where the '@' symbol is used/encouraged in stored procedures. This is useful because you can easily see what is a column and what is a value. For example.
CREATE PROCEDURE Foo
@Bar VARCHAR(10),
@Baz INT
AS
BEGIN
INSERT INTO MyTable (
Bar,
Baz)
VALUES (
@Bar,
@Baz)
END
I know that I can just use ordinal position but some of our stored procs have 20 or so parameters and the named parameter makes it much more legible IMO.
Is there some sort of convention that the PostgreSQL communitiy uses for a prefix? I tried to find out exactly what the rules were for named parameters but my Googling didn't yield anything.
Parameter identifiers follow the same rules as other identifiers:
http://www.postgresql.org/docs/current/static/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS
http://www.postgresql.org/docs/current/static/xfunc-sql.html#XFUNC-SQL-FUNCTION-ARGUMENTS
It is common to start a parameter identifier with an underscore _
and I think it makes sense although it is not a convention.
It is also possible to avoid ambiguity by qualifying the identifier with the function name
my_funtion.my_parameter
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With