Results 1 to 2 of 2

Thread: fields may not be used in IF, ELSEIF or WHILE Clauses

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Join Date
    Jun 2018

    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.

    LIST $nodeID STRING;
    //Create a list with string values
    //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);

    LET $i=$i+1;
    // 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 08:00 AM.

  2. #2

    Join Date
    Jun 2018
    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