pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Phillip Smith <phillip.smith@weatherbeeta.com.au>
To: pgsql-sql@postgresql.org
Subject: SELECT INSTEAD
Date: Thu, 29 Mar 2007 15:35:52 +1000
Message-ID: <00ab01c771c4$1ec9aa50$9b0014ac@wbaus090> (raw)

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


view thread (4+ messages)  latest in thread

Message-ID: <00ab01c771c4$1ec9aa50$9b0014ac@wbaus090>
Permalink:  ../00ab01c771c4$1ec9aa50$9b0014ac@wbaus090/
Also on:    postgresql.org/message-id/00ab01c771c4$1ec9aa50$9b0014ac@wbaus090

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: phillip.smith@weatherbeeta.com.au
  Subject: Re: SELECT INSTEAD
  In-Reply-To: <00ab01c771c4$1ec9aa50$9b0014ac@wbaus090>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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