SELECT INSTEAD - Mailing list pgsql-sql
From | Phillip Smith |
---|---|
Subject | SELECT INSTEAD |
Date | |
Msg-id | 00ab01c771c4$1ec9aa50$9b0014ac@wbaus090 Whole thread Raw |
Responses |
Re: SELECT INSTEAD
Re: SELECT INSTEAD |
List | pgsql-sql |
<div class="Section1"><p class="MsoNormal"><font face="Tahoma" size="2"><span style="font-size:10.0pt; font-family:Tahoma">Hi all,</span></font><p class="MsoNormal"><font face="Tahoma" size="2"><span style="font-size:10.0pt; font-family:Tahoma"> </span></font><p class="MsoNormal"><font face="Tahoma" size="2"><span style="font-size:10.0pt; font-family:Tahoma">I’m trying to create a view of the query below, but I’m being barked at about “rules on SELECT must haveaction 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.</span></font><p class="MsoNormal"style="text-indent:36.0pt"><font face="Tahoma" size="2"><span style="font-size:10.0pt;font-family:Tahoma"> </span></font><pclass="MsoNormal" style="text-indent:36.0pt"><font face="Tahoma"size="2"><span style="font-size:10.0pt;font-family:Tahoma">SELECT DISTINCT ON (m1.id)</span></font><p class="MsoNormal"><fontface="Tahoma" size="2"><span style="font-size:10.0pt; font-family:Tahoma"> UPPER(m1.id) AS id,</span></font><p class="MsoNormal"><font face="Tahoma" size="2"><spanstyle="font-size:10.0pt; font-family:Tahoma"> UPPER(m1.first_name) AS first_name,</span></font><p class="MsoNormal"><font face="Tahoma"size="2"><span style="font-size:10.0pt; font-family:Tahoma"> UPPER(m1.last_name) AS last_name,</span></font><p class="MsoNormal"><font face="Tahoma"size="2"><span style="font-size:10.0pt; font-family:Tahoma"> UPPER(m1.company) AS company,</span></font><p class="MsoNormal"><font face="Tahoma"size="2"><span style="font-size:10.0pt; font-family:Tahoma"> UPPER(m1.address1) AS address1,</span></font><p class="MsoNormal"><font face="Tahoma"size="2"><span style="font-size:10.0pt; font-family:Tahoma"> UPPER(m1.address2) AS address2,</span></font><p class="MsoNormal"><font face="Tahoma"size="2"><span style="font-size:10.0pt; font-family:Tahoma"> UPPER(m1.suburb) AS suburb,</span></font><p class="MsoNormal"><font face="Tahoma"size="2"><span style="font-size:10.0pt; font-family:Tahoma"> UPPER(m1.state) AS state</span></font><p class="MsoNormal" style="text-indent:36.0pt"><fontface="Tahoma" size="2"><span style="font-size:10.0pt;font-family:Tahoma">INTO TEMP TABLEmail_duplicates</span></font><p class="MsoNormal" style="text-indent:36.0pt"><font face="Tahoma" size="2"><span style="font-size:10.0pt;font-family:Tahoma">FROM maillist as m1</span></font><p class="MsoNormal" style="text-indent:36.0pt"><fontface="Tahoma" size="2"><span style="font-size:10.0pt;font-family:Tahoma">INNER JOIN maillistas m2 ON</span></font><p class="MsoNormal"><font face="Tahoma" size="2"><span style="font-size:10.0pt; font-family:Tahoma"> ( m1.id <> m2.id</span></font><p class="MsoNormal"><font face="Tahoma"size="2"><span style="font-size:10.0pt; font-family:Tahoma"> AND UPPER(m1.first_name) = UPPER(m2.first_name)</span></font><p class="MsoNormal"><fontface="Tahoma" size="2"><span style="font-size:10.0pt; font-family:Tahoma"> AND UPPER(m1.last_name) = UPPER(m2.last_name)</span></font><p class="MsoNormal"><fontface="Tahoma" size="2"><span style="font-size:10.0pt; font-family:Tahoma"> AND UPPER(m1.suburb) = UPPER(m2.suburb)</span></font><p class="MsoNormal"><fontface="Tahoma" size="2"><span style="font-size:10.0pt; font-family:Tahoma"> )</span></font><p class="MsoNormal" style="text-indent:36.0pt"><font face="Tahoma"size="2"><span style="font-size:10.0pt;font-family:Tahoma">WHERE TRIM(m1.first_name) <> ''</span></font><pclass="MsoNormal" style="text-indent:36.0pt"><font face="Tahoma" size="2"><span style="font-size:10.0pt;font-family:Tahoma"> AND TRIM(m1.last_name) <> ''</span></font><p class="MsoNormal" style="text-indent:36.0pt"><fontface="Tahoma" size="2"><span style="font-size:10.0pt;font-family:Tahoma">;</span></font><pclass="MsoNormal" style="text-indent:36.0pt"><font face="Tahoma"size="2"><span style="font-size:10.0pt;font-family:Tahoma">SELECT d.id AS "ID",</span></font><p class="MsoNormal"><fontface="Tahoma" size="2"><span style="font-size:10.0pt; font-family:Tahoma"> INITCAP(d.first_name) AS first_name,</span></font><p class="MsoNormal"><fontface="Tahoma" size="2"><span style="font-size:10.0pt; font-family:Tahoma"> INITCAP(d.last_name) AS last_name,</span></font><p class="MsoNormal"><font face="Tahoma"size="2"><span style="font-size:10.0pt; font-family:Tahoma"> INITCAP(d.company) AS company,</span></font><p class="MsoNormal"><font face="Tahoma"size="2"><span style="font-size:10.0pt; font-family:Tahoma"> INITCAP(d.address1) AS address1,</span></font><p class="MsoNormal"><font face="Tahoma"size="2"><span style="font-size:10.0pt; font-family:Tahoma"> INITCAP(d.address2) AS address2,</span></font><p class="MsoNormal"><font face="Tahoma"size="2"><span style="font-size:10.0pt; font-family:Tahoma"> d.suburb AS suburb,</span></font><p class="MsoNormal"><font face="Tahoma" size="2"><spanstyle="font-size:10.0pt; font-family:Tahoma"> d.state AS state</span></font><p class="MsoNormal" style="text-indent:36.0pt"><fontface="Tahoma" size="2"><span style="font-size:10.0pt;font-family:Tahoma">FROM mail_duplicatesAS d</span></font><p class="MsoNormal" style="text-indent:36.0pt"><font face="Tahoma" size="2"><span style="font-size:10.0pt;font-family:Tahoma">ORDERBY d.last_name, d.first_name, d.suburb, d.id</span></font><p class="MsoNormal"style="text-indent:36.0pt"><font face="Tahoma" size="2"><span style="font-size:10.0pt;font-family:Tahoma">;</span></font></div><br/><p><b>*******************Confidentiality and PrivilegeNotice*******************</b><p> 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 replyemail. <p> Information in this message that does not relate to the official business of Weatherbeeta must be treatedas neither given nor endorsed by Weatherbeeta. Weatherbeeta, its employees, contractors or associates shall not beliable for direct, indirect or consequential loss arising from transmission of this message or any attachments <br />