Re: Update using non-existent fields does not throw an error

From: Alban Hertroys <haramrae(at)gmail(dot)com>
To: Rob Richardson <RDRichardson(at)rad-con(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Update using non-existent fields does not throw an error
Date: 2015-03-16 16:07:21
Message-ID: CAF-3MvNkvMup5uLbNg0GdSSYk1bbGeJE8fKW4vGW+hwhyhSLhA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 16 March 2015 at 17:02, Rob Richardson <RDRichardson(at)rad-con(dot)com> wrote:
> Greetings!
>
>
>
> An update query is apparently succeeding, even though the query refers to
> fields that do not exist. Here’s the query:
>
>
>
> update inventory set
>
> x_coordinate = (select x_coordinate from bases where base = '101'),
>
> y_coordinate = (select y_coordinate from bases where base = '101')
>
> where charge = 100
>
>
>
> -- select x_coordinate, y_coordinate from bases where base = '101'
>
>
>
> When I run the update query, it tells me that the query succeeded and that
> four records were updated, which is what I expect. But when I looked at the
> inventory table, I found that the four records were unchanged. So, I tried
> to check the values of the base coordinates by running the select statement
> shown above. That statement threw an error complaining that x_coordinate
> and y_coordinate did not exist. This is correct; I should have been
> querying a view that includes those fields. But why didn’t the update
> statement throw an error?

Because inventory contains those fields.

--
If you can't see the forest for the trees,
Cut the trees and you'll see there is no forest.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Albe Laurenz 2015-03-16 16:20:40 Re: Update using non-existent fields does not throw an error
Previous Message Rob Richardson 2015-03-16 16:02:32 Update using non-existent fields does not throw an error