pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedCascade delete question
2+ messages / 2 participants
[nested] [flat]
* Cascade delete question
@ 2004-04-22 20:46 Glenn MacGregor <gtm@highstreetnetworks.com>
0 siblings, 1 reply; 2+ messages in thread
From: Glenn MacGregor @ 2004-04-22 20:46 UTC (permalink / raw)
To: pgsql-admin
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
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Cascade delete question
@ 2004-04-23 03:03 Bruno Wolff III <bruno@wolff.to>
parent: Glenn MacGregor <gtm@highstreetnetworks.com>
0 siblings, 0 replies; 2+ messages in thread
From: Bruno Wolff III @ 2004-04-23 03:03 UTC (permalink / raw)
To: Glenn MacGregor <gtm@highstreetnetworks.com>; +Cc: pgsql-admin
On Thu, Apr 22, 2004 at 16:46:31 -0400,
Glenn MacGregor <gtm@highstreetnetworks.com> wrote:
>
> 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
>
> Can I change my delete cascade constraint to do this substring query
> instead of an exact match?
No.
> Is there anyway to accomplish what I need to do?
If the local part of the email address is a candidate key, separate it
from the domain name and make it the primary key.
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2004-04-23 03:03 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-04-22 20:46 Cascade delete question Glenn MacGregor <gtm@highstreetnetworks.com>
2004-04-23 03:03 ` Bruno Wolff III <bruno@wolff.to>
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