Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 0D51B63ECAD for ; Sat, 21 Feb 2009 04:43:41 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 33716-06 for ; Sat, 21 Feb 2009 04:43:37 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mailsrv1.zmi.at (mailsrv1.zmi.at [212.69.162.198]) by mail.postgresql.org (Postfix) with ESMTP id 8745B63EC2D for ; Sat, 21 Feb 2009 04:43:37 -0400 (AST) Received: from mailsrv2.i.zmi.at (h081217054243.dyn.cm.kabsi.at [81.217.54.243]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client CN "mailsrv2.i.zmi.at", Issuer "power4u.zmi.at" (not verified)) by mailsrv1.zmi.at (Postfix) with ESMTP id 3702841E0 for ; Sat, 21 Feb 2009 09:43:36 +0100 (CET) Received: from saturn.localnet (saturn.i.zmi.at [10.0.0.2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mailsrv2.i.zmi.at (Postfix) with ESMTPSA id 3A34040016F for ; Sat, 21 Feb 2009 09:43:36 +0100 (CET) From: Michael Monnerie Organization: it-management http://it-management.at To: pgsql-admin@postgresql.org Subject: Question on rule Date: Sat, 21 Feb 2009 09:43:35 +0100 User-Agent: KMail/1.10.3 (Linux/2.6.27.13-ZMI; KDE/4.1.3; x86_64; ; ) MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart2321333.nZD1C8iBUU"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit Message-Id: <200902210943.35832@zmi.at> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200902/165 X-Sequence-Number: 31386 --nextPart2321333.nZD1C8iBUU Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline I have a question to creating a rule: CREATE RULE dbmail_mailboxes_autocreate AS ON INSERT TO dbmail_users DO=20 ALSO insert into dbmail_mailboxes (owner_idnr,name) values=20 (NEW.user_idnr,'INBOX'), (NEW.user_idnr,'Gesendete Objekte'),=20 (NEW.user_idnr,'Entw=C3=BCrfe'), (NEW.user_idnr,'Junk'),=20 (NEW.user_idnr,'Papierkorb'); ERROR: VALUES must not contain OLD or NEW references TIP: Use SELECT ... UNION ALL ... instead. But in http://www.postgresql.org/docs/8.3/interactive/rules-update.html=20 the examples also use NEW in the values. Or can I only use a rule within=20 the same table? If I need to use a TRIGGER: I tried with creating a function, but I=20 don't know how to pass the current user_idnr to that function from the=20 trigger. I managed to create the function: CREATE FUNCTION dbmail_mailboxes_autocreate_function(user_idnr bigint)=20 returns integer AS $$ BEGIN insert into dbmail_mailboxes=20 (owner_idnr,name) values (user_idnr,'INBOX'), (user_idnr,'Gesendete=20 Objekte'), (user_idnr,'Entw=C3=BCrfe'), (user_idnr,'Junk'),=20 (user_idnr,'Papierkorb'); END; $$ LANGUAGE plpgSQL; But I don't know how to do the trigger. Can someone help me? mfg zmi =2D-=20 // Michael Monnerie, Ing.BSc ----- http://it-management.at // Tel: 0660 / 415 65 31 .network.your.ideas. // PGP Key: "curl -s http://zmi.at/zmi.asc | gpg --import" // Fingerprint: AC19 F9D5 36ED CD8A EF38 500E CE14 91F7 1C12 09B4 // Keyserver: wwwkeys.eu.pgp.net Key-ID: 1C1209B4 --nextPart2321333.nZD1C8iBUU Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) iEYEABECAAYFAkmfvrcACgkQzhSR9xwSCbRABQCghV2ocyZOpszcM5bsfbpz7Z98 olYAn1MkJfIWxwpvDmqW13vIa6FP4KtG =4Bin -----END PGP SIGNATURE----- --nextPart2321333.nZD1C8iBUU--