2

I am creating trigger for log table. In that trigger i want to store xuserno to log table. xuserno is a argument of all function

example:

CREATE OR REPLACE FUNCTION fn_consume(xmode text, xuserno integer)
  RETURNS text AS
....
.....
.....

END;

Each table have this type of function. So how can i access the xuserno in my trigger. How can i create global variable for this purpose? or any other solution is have achive this?

1

1 Answer 1

1

It is possible to use transaction-local custom GUCs for this purpose but it's not usually a great idea.

In most cases it is preferable to just use an ON COMMIT DROP temporary table with a single row containing the value of interest.

See:

Sign up to request clarification or add additional context in comments.

2 Comments

If am using like this set myapp.user_name=xuserno'; xuserno is argument of function. Using this for get value SELECT current_setting('myapp.user_name') but it show xuserno not a ` xuserno value ` why? Are anything am doing wrong
@SATSON From the information you've given I couldn't possibly say. Post a new question with the full code of the procedure in complete, runnable form along with your PostgreSQL version etc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.