Coder Social home page Coder Social logo

experiments's People

Contributors

helllth avatar

Watchers

 avatar

experiments's Issues

Proof read

Hi negroscuro,

I think your update statement is problematic, since the from clause in an update statement doesn't produce the cartesian product you are used from a select statement. Therefore it is not deterministic, meaning that it is not guaranteed that the statement always returns the same result.

If we reduce the dimension of the problem (from 2d to 1d) it is more easier to understand:

CREATE TABLE trees (
    name text,
    fromT int,
    toT int
);

CREATE TABLE vegetation (
    name text,
    fromV int,
    toV int,
    updated text
) ;



insert into trees (name, fromT, toT) 
values
('T1',0,8),
('T2',9,13),
('T3',0,6),
('T4',16,17);

insert into vegetation (name, fromV, toV, updated) 
values
('V1',0,10,''),
('V2',5,8,''),
('V3',8,15,'');

First I write a select statement and print out every vegetation that should be updated and with which matching tree dataset.

select v.name || ' should be updated with ' || t.name from trees t,vegetation v 
where 
-- within
(fromV <= fromT AND toV>= toT) OR
-- overlaps
((toV >= fromT AND toT>= toV ) OR (fromT<=fromV AND toT <= toV)) 
order by 1;

This will give us something like this:

Bildschirmfoto 2019-05-09 um 13 02 25

Now I am writing an update statement with the same WHERE clause and the same text result as in the SELECT statement, but I update the field updated of the vegetation table:

update vegetation 
set updated= updated || vegetation.name || ' should be updated with ' || trees.name || ';' -- add the update stirg to the existing value to proof the the update set is only executed once
from trees
where 
-- within
(fromV <= fromT AND toV>= toT) OR
-- overlaps
((toV >= fromT AND toT>= toV ) OR (fromT<=fromV AND toT <= toV));

I can then have a look on the result with:

select name,updated from vegetation;

... and see something like:

Bildschirmfoto 2019-05-09 um 13 09 42

Well, this is obviously not the result we are looking for 😉


TL;DR

Overthink the above statement. Maybe you can write a select statement first, insert that in a third table and go on with that new table.

🤘

Test Secured Ressources

0002602: WGS84 (Breite und Länge) - vertauschte Werte in der Statuszeile

Mantis Info:

In der Statuszeile von WuNDa/DK sind die Werte für Breite und Länge vertauscht

Das Rathaus liegt bei 51° Nördlicher Breite und 7° Ostlicher Länge

Angezeigt wird "7.20,51.27"

Die Beschreibung im Auswahlmenü der Bezugssystem ist korrekt (WGS84-Breite/Laenge)

Additional Information:

Platform: PC

OS: Windows XP/Vista

OS Version: 1

Product Version:

Target Version:

Reproducibility: immer

Priority: normal

Severity: Unschönheit

ID: 0002602

Testspezifikation

Entscheidungen

  • Erste Entscheidung
  • Zweite Entscheidung
  • Dritte Entscheidung

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.