X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 8C0DCD1DC2A for ; Thu, 22 Apr 2004 17:44:01 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 15880-08 for ; Thu, 22 Apr 2004 17:44:01 -0300 (ADT) Received: from highstreetnetworks.highstreetnetworks.com (unknown [69.10.137.249]) by svr1.postgresql.org (Postfix) with SMTP id 79EEDD1D501 for ; Thu, 22 Apr 2004 17:43:58 -0300 (ADT) Received: (qmail 7397 invoked from network); 23 Apr 2004 00:00:36 -0000 Received: from ipn36372-e94654.net-resource.net (HELO highstreetnetworks.com) (216.204.182.62) by highstreetnetworks.com with SMTP; 23 Apr 2004 00:00:36 -0000 Message-ID: <40882F27.2050900@highstreetnetworks.com> Date: Thu, 22 Apr 2004 16:46:31 -0400 From: Glenn MacGregor Organization: HighStreet Networks User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.6) Gecko/20040113 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-admin@postgresql.org Subject: Cascade delete question Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200404/299 X-Sequence-Number: 13272 Hi All, Sorry if this is a double post. Here is an example of my table which works vid vname parentname 1 n1@test.com 2 n2@test.com n1@test.com 3 n3@test.com n1@test.com 4 n4@test.com n1@test.com 5 n5@test.com n3@test.com So my simple cascade on delete states that if I delete a row whose vname matches the parentname of any other delete those rows. No problem this works great! Now I have changed my data to vid vname parentname 1 n1@test.com 2 n2@test.com n1 3 n3@test.com n1 4 n4@test.com n1 5 n5@test.com n3 Notice the parentname is a substring of the vname. I can get that substring from a select query select (substring(vname from 0 for position('@' in vname)) from table1 This query returns vname ------ n1 n2 n3 n4 n5 Can I change my delete cascade constraint to do this substring query instead of an exact match? Is there anyway to accomplish what I need to do? Thanks Glenn MacGregor