agora inbox for pgsql-sql@postgresql.org  
help / color / mirror / Atom feed
refer function name by a variable in the function body
3+ messages / 3 participants
[nested] [flat]

* refer function name by a variable in the function body
@ 2016-02-16 15:41 Suresh Raja <suresh.rajaabc@gmail.com>
  2016-02-16 16:15 ` Re: [SQL] refer function name by a variable in the function body hubert depesz lubaczewski <depesz@depesz.com>
  2016-02-17 12:54 ` Re: refer function name by a variable in the function body amulsul <sul_amul@yahoo.co.in>
  0 siblings, 2 replies; 3+ messages in thread

From: Suresh Raja @ 2016-02-16 15:41 UTC (permalink / raw)
  To: pgsql-general@postgresql.org; pgsql-sql

Hi All:

I use the function name in the body of pgsql code of the same function.  Is
the function name set to any variable that i can easily reference.  Now I'm
hard coding the function name in the code.

create or replace function compute_X(a1 text) returns text as
.....
...
Begin
.....
....
select user into user_id;
raise info 'starting function compute_X as %' user_id || timeofday();

end;

In the above Raise info i use select user to get the login role, similarly
can i use a variable for function name which is automatically set by the
system.

Thanks,
-SR

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: [SQL] refer function name by a variable in the function body
  2016-02-16 15:41 refer function name by a variable in the function body Suresh Raja <suresh.rajaabc@gmail.com>
@ 2016-02-16 16:15 ` hubert depesz lubaczewski <depesz@depesz.com>
  1 sibling, 0 replies; 3+ messages in thread

From: hubert depesz lubaczewski @ 2016-02-16 16:15 UTC (permalink / raw)
  To: pgsql-general@postgresql.org; +Cc: Suresh Raja <suresh.rajaabc@gmail.com>

On Tue, Feb 16, 2016 at 09:41:18AM -0600, Suresh Raja wrote:
> I use the function name in the body of pgsql code of the same function.  Is
> the function name set to any variable that i can easily reference.  Now I'm
> hard coding the function name in the code.
> In the above Raise info i use select user to get the login role, similarly
> can i use a variable for function name which is automatically set by the
> system.

There is no such variable, unfortunately.

Also, please don't cross-post to multiple lists - replied only to
-general, as the question is not about sql language.

Best regards,

depesz

-- 
The best thing about modern society is how easy it is to avoid contact with it.
                                                             http://depesz.com/


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: refer function name by a variable in the function body
  2016-02-16 15:41 refer function name by a variable in the function body Suresh Raja <suresh.rajaabc@gmail.com>
@ 2016-02-17 12:54 ` amulsul <sul_amul@yahoo.co.in>
  1 sibling, 0 replies; 3+ messages in thread

From: amulsul @ 2016-02-17 12:54 UTC (permalink / raw)
  To: pgsql-sql

>raise info 'starting function compute_X as %' user_id || timeofday();

Use 'user' or 'current_user' instead of user_id, it will work. You've typo,
comma is missing before user_id.

Regards,
Amul Sul



--
View this message in context: http://postgresql.nabble.com/refer-function-name-by-a-variable-in-the-function-body-tp5887848p588801...
Sent from the PostgreSQL - sql mailing list archive at Nabble.com.


-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2016-02-17 12:54 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2016-02-16 15:41 refer function name by a variable in the function body Suresh Raja <suresh.rajaabc@gmail.com>
2016-02-16 16:15 ` hubert depesz lubaczewski <depesz@depesz.com>
2016-02-17 12:54 ` amulsul <sul_amul@yahoo.co.in>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox