[NOVICE] Using set role inside a function question

Поиск
Список
Период
Сортировка
От Garry Chen
Тема [NOVICE] Using set role inside a function question
Дата
Msg-id FBAAE934-3C4A-4E01-9FE9-3BCD4402332A@cornell.edu
обсуждение исходный текст
Ответы Re: [NOVICE] Using set role inside a function question  ("Vianello, Daniel A" <Daniel.Vianello@charter.com>)
Список pgsql-novice

Hi All,

                I have a function pass in a user login id (p_runas_id) and the it will insert a row into a table after that set role to that pass in id.   This function complied fine but getting ERROR:  role "p_runas_id" does not exist CONTEXT:  SQL statement "SET ROLE p_runas_id" when execute.  Any suggestion?

 

Thank you very much,

Garry

 

 

CREATE OR REPLACE FUNCTION set_netid_context(p_runas_id       varchar(30))

RETURNS void

AS $$

Declare

     v_dm_name                    varchar(30);

     v_runid                                             varchar(30);

     v_ora_id               numeric;

 

BEGIN

      INSERT INTO obiee_context_audit(context_date, ora_sid, db_user, runas_id)

   VALUES (now(), pg_backend_pid(), SESSION_USER, p_runas_id);

      SET ROLE p_runas_id;

END; $$

LANGUAGE plpgsql;

 

В списке pgsql-novice по дате отправления:

Предыдущее
От: Stephen Froehlich
Дата:
Сообщение: [NOVICE] Re: Old solutions for listing tables by tablespace broken in PG 10for partitions.
Следующее
От: "Vianello, Daniel A"
Дата:
Сообщение: Re: [NOVICE] Using set role inside a function question