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 UAA11654 for postgres-redist; Mon, 27 Jun 1994 20:30:45 -0700 Resent-From: POSTGRES mailing list Resent-Message-Id: <199406280330.UAA11654@nobozo.CS.Berkeley.EDU> X-Authentication-Warning: nobozo.CS.Berkeley.EDU: Host localhost didn't use HELO protocol Sender: owner-postman@postgres.Berkeley.EDU X-Return-Path: owner-postman Received: from ccvcom.auckland.ac.nz (ccvcom.auckland.ac.nz [130.216.1.2]) by nobozo.CS.Berkeley.EDU (8.6.4/8.6.3) with ESMTP id UAA11644 for ; Mon, 27 Jun 1994 20:30:42 -0700 Received: from comu11.auckland.ac.nz by ccvcom.auckland.ac.nz (PMDF V4.3-7 #2864) id <01HE2WU8PDIO8X0M0C@ccvcom.auckland.ac.nz>; Tue, 28 Jun 1994 15:32:45 GMT+1200 Received: by comu11.auckland.ac.nz (4.1/SMI-4.1) id AA21637; Tue, 28 Jun 94 15:31:20 NZS Date: Tue, 28 Jun 1994 15:31:19 +1200 (NZST) From: bruce@comu11.auckland.ac.nz (Bruce Thomson) Subject: PQExec inside a C function? To: postgres@postgres.Berkeley.EDU Cc: bruce@ccvcom.auckland.ac.nz (Bruce Thomson) Message-id: <9406280331.AA21637@comu11.auckland.ac.nz> MIME-version: 1.0 X-Mailer: ELM [version 2.4 PL21] Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit Content-length: 1964 Resent-To: postgres-redist@postgres.Berkeley.EDU Resent-Date: Mon, 27 Jun 94 20:30:45 -0700 Resent-XMts: smtp I am trying to call a user function from within the monitor that should do some PQExec'd insertions into a table. The function is shown below. Unfortunately, I get the following results from 'monitor'. Can I execute embedded postquel statements in this way? If not, what would be the best way to eventually call an external program, and insert its results (from an output file) into a table, all from a monitor retrieve command? Thanks for any help. ----------------------------------------------- Welcome to the POSTGRES terminal monitor Go * define function isert_row (language="C", returntype=int4) arg is (int4) as "/home/sun/bruce/postgres/pqexec/insert.so"\g Query sent to backend is "define function isert_row (language="C", returntype=int4) arg is (int4) as "/home/sun/bruce/postgres/pqexec/insert.so"" DEFINE Go * load "/home/sun/bruce/postgres/pqexec/insert.so"\g Query sent to backend is "load "/home/sun/bruce/postgres/pqexec/insert.so"" LOAD Go * retrieve (result=insert_row(5))\g Query sent to backend is "retrieve (result=insert_row(5))" FATAL: no response from backend: detected in dump_data Go * retrieve (twoval.all)\g Query sent to backend is "retrieve (twoval.all)" FATAL: no response from backend: detected in PQexec Go * \q Broken pipe ----------------------------- #include #include "tmp/libpq.h" int insert_row(x) int x; { char append_line[100]; /* care not to run over the length */ PQsetdb ("external"); PQexec("begin"); sprintf(append_line,"append twovals(x1=%d,x2=%d)",x,x*2); PQexec(append_line); PQexec("end"); PQfinish(); return(0); } ------------------------------- ----------------------------------------------------------------------------- Bruce Thomson bruce@comu11.auckland.ac.nz e-mail for pgp key ----------------------------------------------------------------------------- ============================================================================== 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. ==============================================================================