Return-Path: owner-postman
Received: from localhost (localhost [127.0.0.1]) by nobozo.CS.Berkeley.EDU (8.6.4/8.6.3) with SMTP id XAA12456 for postgres-redist; Mon, 27 Jun 1994 23:48:57 -0700
Resent-From: POSTGRES mailing list <postman@postgres.Berkeley.EDU>
Resent-Message-Id: <199406280648.XAA12456@nobozo.CS.Berkeley.EDU>
Sender: owner-postman@postgres.Berkeley.EDU
X-Return-Path: owner-postman
Received: from faerie.CS.Berkeley.EDU (faerie.CS.Berkeley.EDU [128.32.149.14]) by nobozo.CS.Berkeley.EDU (8.6.4/8.6.3) with ESMTP id XAA12446 for <postgres@postgres.Berkeley.EDU>; Mon, 27 Jun 1994 23:48:56 -0700
Received: from localhost (localhost [127.0.0.1]) by faerie.CS.Berkeley.EDU (8.6.4/8.1B) with SMTP id XAA11001; Mon, 27 Jun 1994 23:48:46 -0700
Message-Id: <199406280648.XAA11001@faerie.CS.Berkeley.EDU>
X-Authentication-Warning: faerie.CS.Berkeley.EDU: Host localhost didn't use HELO protocol
From: aoki@CS.Berkeley.EDU (Paul M. Aoki)
To: bruce@comu11.auckland.ac.nz (Bruce Thomson)
Cc: postgres@postgres.Berkeley.EDU
Subject: Re: PQExec inside a C function? 
Reply-To: aoki@CS.Berkeley.EDU (Paul M. Aoki)
In-reply-to: Your message of Tue, 28 Jun 1994 15:31:19 +1200 (NZST) 
	     <9406280331.AA21637@comu11.auckland.ac.nz> 
Date: Mon, 27 Jun 94 23:48:46 -0700
X-Sender: aoki@postgres.Berkeley.EDU
Resent-To: postgres-redist@postgres.Berkeley.EDU
X-Mts: smtp
Resent-Date: Mon, 27 Jun 94 23:48:57 -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.

in general this interface has a lot of problems.  i don't particularly
recommend it though the alternative (direct access method calls) isn't
very nice either.
--
  Paul M. Aoki  |  CS Div., Dept. of EECS, UCB  |  aoki@CS.Berkeley.EDU
                |  Berkeley, CA 94720-1776      |  ...!uunet!ucbvax!aoki

==============================================================================
   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.
==============================================================================
