Thread: Read values from Trigger out

Read values from Trigger out

From
Thomas Egge
Date:
I have created a trigger function.

could somebody tell me how I get the values from the insert in the trigger
function.
I tried the function

SPI_getvalue(trigger,tupdesc,attnum)

but after starting the trigger, I become this terminating output:

pqReadData() -- backend closed the channel unexpectedly.
        This probably means the backend terminated abnormally
        before or while processing the request.
We have lost the connection to the backend, so further processing is impossible.  Terminating.


thank's for your help
--
Thomas Egge

Re: [GENERAL] Read values from Trigger out

From
"Nilesh A. Phadke"
Date:
Hello Thomas,
 I have used the same thing and it does work for me.... I was also getting
similar problems initially....

What does your trigger do? does it insert a tuple back into the table? if
yes then that is your problem ... coz the insert will fire another trigger
and this may continue endlessly....

Nilesh.


On Wed, 9 Feb 2000, Thomas Egge wrote:

> I have created a trigger function.
>
> could somebody tell me how I get the values from the insert in the trigger
> function.
> I tried the function
>
> SPI_getvalue(trigger,tupdesc,attnum)
>
> but after starting the trigger, I become this terminating output:
>
> pqReadData() -- backend closed the channel unexpectedly.
>         This probably means the backend terminated abnormally
>         before or while processing the request.
> We have lost the connection to the backend, so further processing is impossible.  Terminating.
>
>
> thank's for your help
> --
> Thomas Egge
>
> ************
>
>

-------------------------------------------------------------------
Your intellect is the best gift given to you by god                |
How you use it decides your gift back to him........               |
-------------------------------------------------------------------
Nilesh Phadke                  | e-mail: nilesh@collegemail.com    |
Graduate Research Asstt.       | Phone : (540) 951 8399            |
Department of Computer Science | Addr  : 1011 University City Blvd |
Virginia Tech.                 |         Apt I-7                   |
                               |         Blacksburg, VA 24060      |
-------------------------------------------------------------------


Re: [GENERAL] Read values from Trigger out

From
Karel Zak - Zakkr
Date:


On Wed, 9 Feb 2000, Thomas Egge wrote:

> I have created a trigger function.
>
> could somebody tell me how I get the values from the insert in the trigger
> function.
> I tried the function
>
> SPI_getvalue(trigger,tupdesc,attnum)
>


Example:

        TupleDesc       tupdesc;
        HeapTuple       rettuple        = NULL;
    char        *value;

        if (!CurrentTriggerData)
                elog(ERROR, "triggers are not initialized");

        if (TRIGGER_FIRED_BY_UPDATE(CurrentTriggerData->tg_event))
                rettuple = CurrentTriggerData->tg_newtuple;
        else if (TRIGGER_FIRED_BY_INSERT(CurrentTriggerData->tg_event))
                rettuple = CurrentTriggerData->tg_trigtuple;
        else if (TRIGGER_FIRED_BY_DELETE(CurrentTriggerData->tg_event))
                rettuple = CurrentTriggerData->tg_trigtuple;


        tupdesc = CurrentTriggerData->tg_relation->rd_att;

        if (SPI_connect() < 0)
                elog(ERROR, "SPI_connect()");

    value = SPI_getvalue(rettuple, tupdesc, SPI_fnumber(tupdesc, "column_name"));


 ...see the PostgreSQL programmer's guide for more...

                        Karel


NT binary dbd or odbc?

From
Date:
To please my customer, I'm porting an app from Linux/PG/perl-cgi
to NT/MSsql/perl-cgi. In the process, I'd like to make some testing.
so, I need perl-cgi on NT talk to pg on linxu.
questions:
1) Should I use DBD::PG or use DBD::ODBC.
2) Where I can get the binary files (I do not have the
  compiler -- even if I have, I do not want to get into THAT).

thanks!!!

Kai




pgFlush() -- connection not open

From
M.Mazurek@poznan.multinet.pl
Date:
Hi,
I'm writing some small postgres2www aplication useing jdbc and large
objects.
During testing with heavy load of it I managed to mess up everything:)
I can connect do ny databese but I can't do any query, eg:
bannerdb=> \dt
pqFlush() -- connection not open
It happens with all db I have, I can;t destroy them and recreate them
(same error), I can't vacuum them. Is there any solution except deleteing
data dir adn reinitializing db?
thx
mazek