pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: S Kalyanasundaram <ranjani@niksun.com>
To: pgsql-sql@postgresql.org
Subject: PL/pgSQL - ecpg
Date: Wed, 12 Apr 2000 15:28:25 -0400
Message-ID: <38F4CE59.444423A9@niksun.com> (raw)

When i call the procedure below from a ecpg program i get
sql error too few arguments.. before and after executing the function..
can somebody help me??
thanks in advance
ranjani.


CREATE FUNCTION insert_zone_man(varchar,varchar,int4,int4) RETURNS int4
AS '
   DECLARE
 tmp RECORD;
 p_ip ALIAS FOR $1;
  c_ip ALIAS FOR $2;
 sts ALIAS FOR $3;
 zm_flg ALIAS FOR $4;
   BEGIN
        IF p_ip IS NOT NULL THEN
  SELECT INTO tmp ip_address FROM Node WHERE node.ip_address = ''p_ip'';

         IF NOT FOUND THEN
      INSERT INTO Node VALUES(c_ip,sts,zm_flg);
  END IF;

 END IF;
    RETURN 1;
  END;
' LANGUAGE 'plpgsql';

I am calling this function from test.pgc program as follows..

#include <stdio.h>

exec sql include sqlca;
exec sql whenever sqlerror sqlprint;

int
main ()
{
exec sql begin declare section;
 char command[500];
exec sql end declare section;
     char msg[128];
     FILE *dbgs;
     int i,j;

     if((dbgs = fopen("log", "w")) != NULL)
       ECPGdebug(1, dbgs);

     strcpy(msg, "connect");
     exec sql connect to distributed;

     strcpy(msg, "calling function");
     sprintf(command , "SELECT
insert_zone_man('10.0.0.1'::varchar,'10.0.0.112'::varchar,1::int,1::int)");

     exec sql execute immediate :command;


     strcpy(msg,"disconnect");
     exec sql disconnect;

     if(dbgs != NULL)
       fclose(dbgs);

     return(0);
}





Message-ID: <38F4CE59.444423A9@niksun.com>
Permalink:  ../38F4CE59.444423A9@niksun.com/
Also on:    postgresql.org/message-id/38F4CE59.444423A9@niksun.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: ranjani@niksun.com
  Subject: Re: PL/pgSQL - ecpg
  In-Reply-To: <38F4CE59.444423A9@niksun.com>
  References: <38F4CE59.444423A9@niksun.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox