-
June 12, 2018, 12:10 PM
#1
fields may not be used in IF, ELSEIF or WHILE Clauses
I want to do some extra calculation to the population values of the subcatchments. I'm able to do it partially. I tweaked a sql code that I found and I can do some computation to the population of the subcatchments. However when I'm trying to filter certain subcatchments by using IF statement and land_use_id as a condition it doesn't let me do it.
What I'm trying to archive is to filter the selected subcatchment by land_use_id and then do extra computation to the population value of each selected subcatchments.
Code
LIST $nodeID STRING;
//Create a list with string values
SELECT SELECTED DISTINCT node_id INTO $nodeID FROM [All Nodes];
//Store distinct node values it made it scalar.
LET $i=1;
// Variable for the loop
WHILE $i<=LEN($nodeID);
//start of While loop
DESELECT ALL FROM [All Nodes];
SELECT FROM [All Nodes] WHERE node_id= AREF($i,$nodeID);
UPDATE [ALL Links] SET $link_selected = 0;
UPDATE [ALL Nodes] SET $node_selected = 0;
UPDATE SELECTED SET $node_selected = 1;
SELECT FROM [All Nodes] WHERE $node_selected = 1;
UPDATE Subcatchment SET $subcatchment_selected =0;
UPDATE SELECTED SET subcatchments.$subcatchment_selected =1;
DESELECT ALL From Subcatchment;
SELECT FROM Subcatchment WHERE $subcatchment_selected =1;
SELECT SELECTED (population) INTO $Population_1 FROM Subcatchment;
SELECT FROM [All Nodes] WHERE node_id= AREF($i,$nodeID);
UPDATE SELECTED SET user_number_1 = $Population_1 ;
// Moving the Population value to the user define
UPDATE SELECTED SET user_number_2= user_number_1 * 10;
//
IF land_use_id = 'jk';
INSERT INTO subcatchment(user_number_3) VALUES ($Population_1 / 5);
ENDIF;
LET $i=$i+1;
//Increment
WEND;
// Terminator of the While Loop
DESELECT ALL FROM [All Nodes];
// DESELECT everything FROM ALL Nodes
DESELECT ALL FROM Subcatchment;
// DELECT everything FROM Subcatchment
Last edited by Zesima29; July 7, 2018 at 09:00 AM.
-
June 13, 2018, 12:42 PM
#2
Okay since the IF statements where not working, I moved to WHERE statements where I can filter the values.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules