Return-Path: owner-postman
Received: from localhost.Berkeley.EDU (localhost.Berkeley.EDU [127.0.0.1]) by nobozo.CS.Berkeley.EDU (8.6.4/8.6.3) with SMTP id EAA13519 for postgres-redist; Tue, 28 Jun 1994 04:21:06 -0700
Resent-From: POSTGRES mailing list <postman@postgres.Berkeley.EDU>
Resent-Message-Id: <199406281121.EAA13519@nobozo.CS.Berkeley.EDU>
X-Authentication-Warning: nobozo.CS.Berkeley.EDU: Host localhost.Berkeley.EDU didn't use HELO protocol
Sender: owner-postman@postgres.Berkeley.EDU
X-Return-Path: owner-postman
Received: from ks.mpi-dortmund.mpg.de (ks.mpi-dortmund.mpg.de [141.5.68.16]) by nobozo.CS.Berkeley.EDU (8.6.4/8.6.3) with SMTP id EAA13506 for <postgres@postgres.Berkeley.EDU>; Tue, 28 Jun 1994 04:20:36 -0700
Received: from dl.mpi-dortmund.mpg.de by ks.mpi-dortmund.mpg.de (4.1/SMI-4.1MHS-mpi-1.4.93)
	id AA14364; Tue, 28 Jun 94 13:20:24 +0200
Received: by dl.mpi-dortmund.mpg.de (4.1/SMI-4.1-mpi-30.3.93)
	id AA10298; Tue, 28 Jun 94 13:20:21 +0200
Date: Tue, 28 Jun 94 13:20:21 +0200
From: joerg.plewe@mpi-dortmund.mpg.de (J.Plewe)
Message-Id: <9406281120.AA10298@dl.mpi-dortmund.mpg.de>
To: postgres@postgres.Berkeley.EDU
Subject: Re: PQExec inside a C function?
Resent-To: postgres-redist@postgres.Berkeley.EDU
Resent-Date: Tue, 28 Jun 94 04:20:41 -0700
Resent-XMts: smtp


> bruce@comu11.auckland.ac.nz (Bruce Thomson) writes:
> > I am trying to call a user function from within the monitor that should
> > do some PQExec'd insertions into a table.
> 
> > PQsetdb ("external");
> > PQexec("begin");
>           ^^^^^
> > sprintf(append_line,"append twovals(x1=%d,x2=%d)",x,x*2);
> > PQexec(append_line);
> > PQexec("end");
>           ^^^
> 
> if this is postgres 4.x, x<2, this won't work at all.
> 
> if this is 4.2, you stand some chance but you don't want to use begin/end.
> (all backend "libpq" calls are executed in the same transaction already.)
> you also don't want to link your function with libpq, *ever*, if it's going
> to be used in the backend -- there are equivalent functions in the backend.
> i don't think you need to do PQsetdb since you're already in a backend
> that is attached to a database.

To my opinion, PQsetdb ist *not* defined in the backend, so you cannot even 
use it.

I tried to do a PQexec without PQsetdb, and it worked as expected.


- Joerg


*********************************************************************
Dipl. Phys. Joerg Plewe               joerg.plewe@mpi-dortmund.mpg.de
MPI fuer molekulare Physiologie
Rheinlanddamm 201
44139 Dortmund
Germany                               +49 (0)231 1206 384
*********************************************************************





==============================================================================
   To add/remove yourself to/from the POSTGRES mailing list: send mail with 
   the subject line ADD or DEL to "postgres-request@postgres.Berkeley.EDU"

   If this fails, send mail to "post_questions@postgres.Berkeley.EDU" and
   a human will deal with it.  DO NOT post to the "postgres" mailing list.
==============================================================================
