Passing variables to PostgreSQL database

Passing variables to PostgreSQL database

Postby ccampbell » Fri 21 Jan 2011 18:21

Using 2010
The latest version
PostgreSQL 9.0.2

Hi, I will ask the question and then explain what I’m doing.

Question: Is there a way to pass a variable from an application user interface to the database such that it would be visible to a database trigger and any corresponding function call?

When a record gets deleted, I have a database trigger that fires and writes to a log table. What I want to do is pass a variable from the user interface to the trigger function so I can include this variable in the log record that gets created. I’m not sure how this could even be accomplished unless somehow it was possible to pass a variable through the data connection itself. But even then, how would the trigger function be able to read it and pass it along?

I’m thinking it’s not possible but thought I would ask anyway.


Chris Campbell
Posts: 29
Joined: Tue 01 Jun 2010 17:31
Location: Oregon

Postby Shalex » Mon 24 Jan 2011 15:43

As a possible solution, you can set the application_name configuration parameter on your connection object and then read its value from the pg_stat_activity view:,
Devart Team
Posts: 7654
Joined: Thu 14 Aug 2008 12:44

Return to dotConnect for PostgreSQL