Received: from mail2.scania.com ([138.106.100.99]) by postgresql.org (8.11.3/8.11.4) with ESMTP id fAFGLtm19992 for ; Thu, 15 Nov 2001 11:21:56 -0500 (EST) (envelope-from roelof.sondaar@wmdata.nl) Received: from virscan3.Scania.se (virscan3.scania.se [138.106.11.202]) by mail2.scania.com (Switch-2.0.3/Switch-2.0.3) with SMTP id fAFGLxK77792 for ; Thu, 15 Nov 2001 17:21:59 +0100 Received: FROM n08606.scania.se BY virscan3.Scania.se ; Thu Nov 15 17:21:58 2001 +0100 Received: from bushmill.scania.se (bushmill.scania.se [138.106.13.95]) by n08606.scania.se (Switch-2.0.3/Switch-2.0.3) with ESMTP id fAFGLwn81046 for ; Thu, 15 Nov 2001 17:21:58 +0100 Received: from wmdata.nl (WS7098 [139.122.161.65]) by bushmill.scania.se with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id V3SBL00X; Thu, 15 Nov 2001 17:21:57 +0100 Message-ID: <3BF3EB9F.E4C5B46E@wmdata.nl> Date: Thu, 15 Nov 2001 17:21:51 +0100 From: Roelof Sondaar Organization: WM-data Zwolle B.V. X-Mailer: Mozilla 4.7 [nl] (WinNT; U) X-Accept-Language: nl MIME-Version: 1.0 To: PostgreSQL SQL list Subject: How to use COPY in a function ? Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Archive-Number: 200111/277 X-Sequence-Number: 5659 Hello, I tried to use COPY in a function. It gives the following message: copyObject: don't know how to copy 610. As I understand from the documentation COPY is not supported in a function. Does anyone a solution to do this in a function ? Or can anyone give me a hint where to find it ? I added the code at the bottom. Thanks, Roelof Sondaar WM-data Zwolle B.V. CREATE FUNCTION dnsdhcp_db_header (text) RETURNS boolean AS ' /* This function create all the DNS db tables for the local networks */ /* It needs one parameter which is the directory where the tables */ /* should be created */ DECLARE directory ALIAS FOR $1; networks record; table text; servers record; data record; BEGIN /**** For each network record create a db file ****/ /* We do this only for the local networks (location = l) */ /* The remote networks (location = r) are for slave use only */ FOR networks IN SELECT * FROM network WHERE location = ''l'' LOOP RAISE NOTICE ''a: %'', networks.id; /* create db. */ IF position(''n'' IN networks.use) > 0 THEN /* Cleanup export table */ DELETE FROM export; INSERT INTO export VALUES(''$'' || networks.ttl); INSERT INTO export VALUES(''; Created on : '' || timestamp(''now'')); INSERT INTO export VALUES(''@ IN SOA '' || networks.domain || '' '' || networks.email || ''. (''); INSERT INTO export VALUES('' '' || text(networks.serial) || '' ; Serial''); INSERT INTO export VALUES('' '' || networks.refresh || '' ; Refresh''); INSERT INTO export VALUES('' '' || networks.retry || '' ; Retry''); INSERT INTO export VALUES('' '' || networks.expire || '' ; Expire''); INSERT INTO export VALUES('' '' || networks.cachettl || '' ) ; Negative caching TTL''); /* Name servers */ FOR servers IN SELECT * FROM server_dns WHERE ipaddress_network = networks.ipaddress LOOP RAISE NOTICE ''b: %'', servers.name; INSERT INTO export VALUES('' IN NS '' || servers.name || ''.''); END LOOP; /* Copy the table to the given location */ RAISE NOTICE ''c: Directory: %'', $1; table:= ''"'' || directory || ''/db.'' || networks.domain || ''"''; RAISE NOTICE ''d: table: %'', table; FOR data IN SELECT * FROM export LOOP RAISE NOTICE ''e: export: %'', data.data; END LOOP; COPY export TO ''/home/snlsor/carbageshshshhshsh''; END IF; END LOOP; RETURN ''t''; END; ' LANGUAGE 'plpgsql';