pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedHow to use COPY in a function ?
2+ messages / 2 participants
[nested] [flat]
* How to use COPY in a function ?
@ 2001-11-15 16:21 Roelof Sondaar <roelof.sondaar@wmdata.nl>
2001-11-20 04:40 ` Re: How to use COPY in a function ? Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 2+ messages in thread
From: Roelof Sondaar @ 2001-11-15 16:21 UTC (permalink / raw)
To: pgsql-sql
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.<domain> */
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';
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: How to use COPY in a function ?
2001-11-15 16:21 How to use COPY in a function ? Roelof Sondaar <roelof.sondaar@wmdata.nl>
@ 2001-11-20 04:40 ` Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 2+ messages in thread
From: Tom Lane @ 2001-11-20 04:40 UTC (permalink / raw)
To: Roelof Sondaar <roelof.sondaar@wmdata.nl>; +Cc: pgsql-sql
Roelof Sondaar <roelof.sondaar@wmdata.nl> writes:
> It gives the following message: copyObject: don't know how to copy 610.
How old is your Postgres? AFAIR this works in 7.1.
regards, tom lane
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2001-11-20 04:40 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-11-15 16:21 How to use COPY in a function ? Roelof Sondaar <roelof.sondaar@wmdata.nl>
2001-11-20 04:40 ` Tom Lane <tgl@sss.pgh.pa.us>
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