View Full Version : query to select upstream network

Jonckheere BVBA
November 14, 2014, 03:17 AM
I want to create a query to
- select the upstream network of a conduit (all upstream links)
- select all the subcatchments that go to this network
- get the value of “population” of these subcatcments and add them all
- fill the solution in user tekst 5 of this conduit.
I have difficulties with step 1: select upstream network.
Is this possible in a query ?

November 17, 2014, 02:08 AM
I don't know if it's possible within a query, but my solution would be to use trace and select links upstream tool and then build the query from this - but I'm no SQL expert :)

Jonckheere BVBA
November 19, 2014, 08:05 AM
I'm this far. I now have the error "Error preparing clausule 5 : 'while$count100UPDAT SET...': SET clause must begin with the keyword SET or the keyword UPDATE. When I remove the While-wend the syntax is correct.
Is it possible work with while-wend in Infoworks-SQL?

UPDATE [All Nodes] SET $node_selected = 0;
UPDATE [ALL Links] SET $link_selected = 0;
UPDATE SELECTED SET $link_selected = 1;
LET $count = 1;
while $count<100
UPDATE SET us_node.$node_selected = 1 WHERE $link_selected = 1;
UPDATE [ALL Nodes] SET us_links.$link_selected = 1 WHERE $node_selected = 1;
$count = $count + 1;
SELECT FROM [All Links] WHERE $link_selected = 1;
SELECT FROM [All Nodes] WHERE $node_selected = 1;

Jonckheere BVBA
November 19, 2014, 08:11 AM
I've found the reason
The SQL sequence will only work in CS v13.5 or later. The WHILE function was one of a number of SQL enhancements added at the v13.5 release

December 23, 2014, 06:08 AM

Did you manage to build the complete query?
I'm trying to write a similar one.