473,782 Members | 2,436 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Adding missing FROM-clause entry in subquery

I run the following script to export some data from my development
database and then update or insert the records into to the quality
assurance testing database, but I get a warning notice that I don't
understand. Aside from that notice, the script appears to work as
intended, i.e., updating existing report definitions and adding any new
ones defined in the dev environment but not appearing in QAT.

Here is the script:

\set ON_ERROR_STOP ON

COPY report TO '/home/postgres/report.sql';

\c paidqat
CREATE TEMPORARY TABLE temptable AS SELECT * FROM report;

DELETE FROM temptable;

COPY temptable FROM '/home/postgres/report.sql';

UPDATE report SET resource = (
SELECT resource FROM temptable s1
WHERE s1.title = report.title)
WHERE EXISTS(SELECT 1 FROM temptable s1
WHERE s1.title = report.title);

INSERT INTO report (
SELECT * FROM temptable s1 EXCEPT
SELECT * FROM report s2 WHERE s2.title = report.title);
The warning notice refers to the last command in the script, i.e., the
INSERT, but inserts do occur successfully as a result.

Here is the run and the resulting notice message:

bash-2.05a$ psql -f urep.sql -U paid paiddev
COPY
You are now connected to database paidqat.
SELECT
DELETE 6
COPY
UPDATE 6
psql:urep.sql:2 0: NOTICE: Adding missing FROM-clause entry in subquery
for table "report"
INSERT 0 1
bash-2.05a$

~Berend Tober


---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postg resql.org so that your
message can get through to the mailing list cleanly

Nov 12 '05 #1
2 6397
On Thu, 2003-10-02 at 08:58, bt****@seaworth ysys.com wrote:

INSERT INTO report (
SELECT * FROM temptable s1 EXCEPT
SELECT * FROM report s2 WHERE s2.title = report.title);


i think you're essentially doing:

INSERT INTO report (
SELECT * FROM temptable s1 EXCEPT
SELECT * FROM report s2, report WHERE s2.title = report.title);

which i don't think is what you expected to happen*, but seems to be
pretty much equivalent in this case.

*given that missing-from behaves differently with inserts and updates, i
can see how this is pretty confusing... in 7.4 theres an option to turn
this off, though you'd need to think of another way to do what your
doing above since it would break
Robert Treat
--
Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 12 '05 #2
On 2 Oct 2003, Robert Treat wrote:
On Thu, 2003-10-02 at 08:58, bt****@seaworth ysys.com wrote:

INSERT INTO report (
SELECT * FROM temptable s1 EXCEPT
SELECT * FROM report s2 WHERE s2.title = report.title);

i think you're essentially doing:

INSERT INTO report (
SELECT * FROM temptable s1 EXCEPT
SELECT * FROM report s2, report WHERE s2.title = report.title);

which i don't think is what you expected to happen*, but seems to be
pretty much equivalent in this case.

*given that missing-from behaves differently with inserts and updates, i
can see how this is pretty confusing...


But in the update case it's not an error because of the extension that allows
the where clause of an update to refer to other tables (I think). Whereas in
the insert case there is no cross over between the table named for insert and
the select cluase generating the data to inserted, it is a complete select
clause in it's own right. Indeed, having written that it's occured to me the
reason behind this specific example, it's to avoid the insert of duplicate key
error. The select in the insert statement should stand as a query in it's own
right but if it didn't all those people looking to avoid transaction abort when
wanting an update or insert if not there already type operation would have
their work around.
in 7.4 theres an option to turn
this off, though you'd need to think of another way to do what your
doing above since it would break


--
Nigel J. Andrews


---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
376
by: pmud | last post by:
In my ASP.Net application I added a required field validator.Before adding this , my application was running fine but after ading this, when i tried to view the .aspx in browser, i got an alert msg saying:: Unable to find script library'/'aspnet_client\system_web\1_1_4322/WebUIValidation.js'. Try replacing this file manually or reinstall by running 'aspnet_client-regiis'. I found the file 'WebUIValidation.js' in the location...
5
5923
by: surrealtrauma | last post by:
the requirement is : Create a class called Rational (rational.h) for performing arithmetic with fractions. Write a program to test your class. Use Integer variables to represent the private data of the class – the numerator and the denominator. Provide a constructor that enables an object of this class to be initialized when it is declared. The constructor should contain default values in case no initializers are provided and should...
7
1324
by: Mathew Hill | last post by:
I am a beginner to the more technical aspects of Microsoft Access (2000) and was wondering if any one can help. I have 3 buttons on a form which add, delete and search for a record. However, when I click on the respective buttons absolutely nothing happens! I was wondering if anyone could help? The code I have is below... ADDING A RECORD Private Sub cmdaddstudent_Click() On Error GoTo Err_cmdaddstudent_Click
1
1728
by: RobMea | last post by:
I am trying to find a solution to the following problem. First off I'm new to Access and SQL but have a good back ground in other languages, thus at a new job this has just been dumped on me so as is my style I agreed figuring that over time it's just another language and style anyway to add to the others I've worked in. Heres my situation. Have used a make table query to establish a Temp historical archive table for reporting...
7
5430
by: Wysiwyg | last post by:
Is there any way to add an embedded resource to a project without copying it to the project's directory? I have shared resources and don't want each project using the images, xml files, etc. to need to be updated with the current copy before being built. I also don't want projects being built with the old copy. Thanks! Bill
3
1955
by: Robin Thomas | last post by:
I am fairly new to ASP.NET so I think I am missing something fundamental. Anyway, quite often I am pulling data from a database, but then I need to use that data to produce more data. A simple example would be: Let's say Column1=StartDate and Column2=EndDate. In addition to displaying Column1 and Column2, I need to do some calculations and display in as Column3. The calculations are easy and can be done in the code-behind. How to display...
1
2638
by: jim4u | last post by:
Hi gurus, I have an automation add-in created using C# for Excel, in which I am exposing a number of functions. Is there any way I can add help-text the way excel does for other categories like Financial, Statistical, etc. The place I want my help-text to be available is in the Insert->Function. Here, we can select a category and function. The corresponding help text is displayed. Now, my automation add-in is
5
9643
by: Steven Smith | last post by:
Hi, I'm trying to write a simple program to print invoices for people I do work for. I've got a form with textboxes for descriptions and amounts for items, and some code for printing the invoices. It all works except for the one line that adds all of the item amounts. At run time, a "type mismatch" error is thrown. I've tried a couple of different things, but the code won't work. Is there something special about adding currency I'm...
5
1975
by: Gustaf | last post by:
Here's what happens: I got a Web Service installed locally on my IIS. Then I got a client project, which will call this service. But when I add the Web Reference to the Web Service, and look at the imported classes with Object Browser, there are classes missing. How can that be? The classes in question are of course public, and I see them in Object Browser in the Web Service project. The classes are auto-generated from an XSD file, using the...
8
19941
by: Jason | last post by:
Hello, I am trying to utilitze the AJAX Control toolkit in my asp.net project. I have added a reference to AjaxControlToolkit.dll, and in my page, added these lines of code: <ajaxToolkit:ToolkitScriptManager runat="Server" EnableScriptGlobalization="true" EnableScriptLocalization="true" ID="ScriptManager1" />
0
9641
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9944
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8968
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7494
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6735
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5378
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4044
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3643
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.