[postgis-users] IF, ELSE, FOR and WHILE in postgis
Daniel Grum
daniel.grum at unibw.de
Mon Oct 12 08:56:15 PDT 2009
Maxime van Noppen schrieb:
> Daniel Grum wrote:
>
>> The SQL-Skript:
>> UPDATE einheiten_und_bewegungen
>> SET the_geom = (SELECT
>> ST_Line_SubString(ST_LineMerge(line.the_geom),(1-((Length(line.the_geom)-1000)
>>
>> /Length(line.the_geom))),1)
>> FROM public.einheiten_und_bewegungen line
>> WHERE length(line.the_geom)>1000
>> ORDER BY line.gid);
>>
>> In the table einheiten_und_bewegungen are more than one line!
>>
>
> Hi,
>
> It seems that the problem of your query is that the SELECT query might
> return more than a row. I thinked what you wanted to write is something
> more like :
>
>
>> UPDATE einheiten_und_bewegungen
>> SET the_geom = ST_Line_SubString(ST_LineMerge(the_geom),(1-((Length(the_geom)-1000)/Length(the_geom))),1)
>> WHERE length(the_geom)>1000;
>>
>
> I don't see why the select is necessary. This UPDATE query will update
> any row where the length of the_geom is >1000 with the formula you provided.
>
>
Super, that works...in my work I allways use the SELECT but don't think
about it enough.
Know I understand what I have to do
More information about the postgis-users
mailing list