Re: stored procedure variable names

From: Jerry Sievers <gsievers19(at)comcast(dot)net>
To: inspector morse <inspectormorse86(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: stored procedure variable names
Date: 2015-02-20 01:16:49
Message-ID: 86mw49s7pa.fsf@jerry.enova.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

inspector morse <inspectormorse86(at)gmail(dot)com> writes:

> In all other DBMS, the variable names have a distinctive character to differentiate between variables and column names:
>
> Example:
> SQL Server uses @
> MySql uses ?
> Oracle uses :
> Firebirdsql uses :
>
> It makes it easier to write and manage queries especially in stored procedures.
>
> Just compare the below:
> create stored procedure get_user_for_editing(user_id int, out username varchar)
> begin
>    select username into @username from users where user_id = @user_id;
> end;
>
> to this mess:
>
> create stored procedure get_user_for_editing(user_id int, out username varchar)
> begin
>    select u.username into get_user_for_editing.username from users u where get_user_for_editing.user_id = get_user_for_editing.user_id;
> end;
>
> Prefixing the variables (ex: p_user_id) makes the application code harder to write as we have a lot of dynamic code that is expecting "user_id" instead of "p_user_id".
>
> Is there any plan to add a character to differentiate between variables?

Not that I'm aware of but please submit a patch or do not hesitate to
run any of those other platforms where things are not such a mess :-)

>

--
Jerry Sievers
Postgres DBA/Development Consulting
e: postgres(dot)consulting(at)comcast(dot)net
p: 312.241.7800

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2015-02-20 01:28:33 Re: stored procedure variable names
Previous Message inspector morse 2015-02-20 00:57:54 stored procedure variable names