SELECT INSTEAD

From: "Phillip Smith" <phillip(dot)smith(at)weatherbeeta(dot)com(dot)au>
To: <pgsql-sql(at)postgresql(dot)org>
Subject: SELECT INSTEAD
Date: 2007-03-29 05:35:52
Message-ID: 00ab01c771c4$1ec9aa50$9b0014ac@wbaus090
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi all,

I'm trying to create a view of the query below, but I'm being barked at
about "rules on SELECT must have action INSTEAD SELECT". I don't have any
rules in my database, and I don't know how this query is trying to create
one. The query does work if I just run it interactively. Any help would be
much appreciated.

SELECT DISTINCT ON (m1.id)

UPPER(m1.id) AS id,

UPPER(m1.first_name) AS first_name,

UPPER(m1.last_name) AS last_name,

UPPER(m1.company) AS company,

UPPER(m1.address1) AS address1,

UPPER(m1.address2) AS address2,

UPPER(m1.suburb) AS suburb,

UPPER(m1.state) AS state

INTO TEMP TABLE mail_duplicates

FROM maillist as m1

INNER JOIN maillist as m2 ON

( m1.id <> m2.id

AND UPPER(m1.first_name) = UPPER(m2.first_name)

AND UPPER(m1.last_name) = UPPER(m2.last_name)

AND UPPER(m1.suburb) = UPPER(m2.suburb)

)

WHERE TRIM(m1.first_name) <> ''

AND TRIM(m1.last_name) <> ''

;

SELECT d.id AS "ID",

INITCAP(d.first_name) AS first_name,

INITCAP(d.last_name) AS last_name,

INITCAP(d.company) AS company,

INITCAP(d.address1) AS address1,

INITCAP(d.address2) AS address2,

d.suburb AS suburb,

d.state AS state

FROM mail_duplicates AS d

ORDER BY d.last_name, d.first_name, d.suburb, d.id

;

*******************Confidentiality and Privilege Notice*******************

The material contained in this message is privileged and confidential to
the addressee. If you are not the addressee indicated in this message or
responsible for delivery of the message to such person, you may not copy
or deliver this message to anyone, and you should destroy it and kindly
notify the sender by reply email.

Information in this message that does not relate to the official business
of Weatherbeeta must be treated as neither given nor endorsed by Weatherbeeta.
Weatherbeeta, its employees, contractors or associates shall not be liable
for direct, indirect or consequential loss arising from transmission of this
message or any attachments

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Michael Fuhr 2007-03-29 06:48:34 Re: SELECT INSTEAD
Previous Message Phillip Smith 2007-03-28 22:21:31 Re: Foreign Unique Constraint