From: | inspector morse <inspectormorse86(at)gmail(dot)com> |
---|---|
To: | Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: stored procedure variable names |
Date: | 2015-02-20 01:47:04 |
Message-ID: | CAHYn==5eXMo1HjhYAxiDzxffpVVtfMxY_i1pX_v1UQ0kyP_jaQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Yeah, I'm using plpgsql.
Actually nevermind on this. I was able to patch my data access utility so
it adds a prefix when calling the stored function and then remove it again
before returning for front end processing.
On Thu, Feb 19, 2015 at 8:44 PM, Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
wrote:
> On 02/19/2015 04:57 PM, inspector morse wrote:
>
>> 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;
>>
>>
> First Postgres does not have stored procedures, but user defined
> functions, so the above is a no-op right from the start.
>
> Second I have no idea where you are pulling get_user_for_editing.* from?
>
> Third, which of the Postgres procedural languages are you having an issue
> with?
>
> 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?
>>
>
> In what procedural language?
>
>
> --
> Adrian Klaver
> adrian(dot)klaver(at)aklaver(dot)com
>
From | Date | Subject | |
---|---|---|---|
Next Message | Ken Tanzer | 2015-02-20 04:18:39 | Array string casts with SELECT but not SELECT DISTINCT |
Previous Message | Adrian Klaver | 2015-02-20 01:44:12 | Re: stored procedure variable names |