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?

Sathish
  • 4,419
  • 4
  • 30
  • 59

1 Answers1

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:

Community
  • 1
  • 1
Craig Ringer
  • 307,061
  • 76
  • 688
  • 778
  • 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 – Sathish Apr 02 '13 at 09:35
  • @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. – Craig Ringer Apr 02 '13 at 10:19