Received: from arjun.niksun.com (gwnew.niksun.com [206.20.52.130]) by hub.org (8.9.3/8.9.3) with ESMTP id PAA92135 for ; Wed, 12 Apr 2000 15:33:15 -0400 (EDT) (envelope-from ranjani@niksun.com) Received: from niksun.com (einstein.niksun.com [10.0.0.50]) by arjun.niksun.com (8.9.3/8.9.3) with ESMTP id PAA24591 for ; Wed, 12 Apr 2000 15:33:13 -0400 (EDT) (envelope-from ranjani@niksun.com) Message-ID: <38F4CE59.444423A9@niksun.com> Date: Wed, 12 Apr 2000 15:28:25 -0400 From: S Kalyanasundaram Reply-To: ranjani@niksun.com Organization: NiKSUN X-Mailer: Mozilla 4.5 [en] (X11; I; FreeBSD 3.2-RELEASE i386) X-Accept-Language: en MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: PL/pgSQL - ecpg Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Archive-Number: 200004/128 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 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); }