PL/pgSQL - ecpg

From: S Kalyanasundaram <ranjani(at)niksun(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: PL/pgSQL - ecpg
Date: 2000-04-12 19:28:25
Message-ID: 38F4CE59.444423A9@niksun.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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);
}

Browse pgsql-sql by date

  From Date Subject
Next Message tjk@tksoft.com 2000-04-12 20:54:52 Re: query from D. N. Murty
Previous Message D.N.MURTY 2000-04-12 19:16:38 query from D. N. Murty