When entering in the following query code into the ‘Write Queries Editor’, GraphStudio (version 3.9.3 - on iCloud) I do not receive an error message.
However, when I compile the code. I do receive an error message that states: “nullSaved as draft query with type/semantic error:[calculateBodyMass]”
The compiler does not recognize using an “IN” as part of the IF statement.
CREATE QUERY calculateBodyMass(UINT hraID) SYNTAX v2 {
/**
-
Build out Body Mass Index
**/
UINT id,height, weight, bmi;Start = {HRA.*};
PRS = SELECT h FROM Start:h WHERE h.id == hraID AND h.height>0 AND h.weight>0
ACCUM bmi = (h.weight * 703)/(h.height * h.height),
id = h.id, height = h.height, weight = h.weight
PRS = SELECT h FROM Start:h WHERE h.id == hraID AND h.height>0 AND h.weight>0
ACCUM bmi = (h.weight * 703)/(h.height * h.height),
id = h.id, height = h.height, weight = h.weight
POST-ACCUM
SET height25 = (61,63,79,81),
SET weight25 = (130,140,220,230),IF bmi > 18 AND bmi <= 25 THEN /* * Handle special case where BMI 25 crosses into Optimal boundaries */ IF bmi == 25 AND height IN height25 AND weight IN weight25 THEN INSERT INTO BodyMass VALUES(id, bmi, height, weight, "Optimal") ELSE IF bmi !=25 THEN INSERT INTO BodyMass VALUES(id, bmi, height, weight, "Optimal") END END;
It seems the query editor allows “IN” statements as part of the IF THEN statement. This should be flagged as an error in the editor if the IF THEN statement doesn’t support the IN operator.
As a feature request, it would be great to have the IF condition IN a SET THEN supported.