From fc869c1580249e27c2c403f6b54ca08a31b7bd99 Mon Sep 17 00:00:00 2001 From: Mingxi Wu Date: Tue, 21 Jan 2025 12:34:14 -0800 Subject: [PATCH] Create IfElseTest.gsql --- .../tutorial/4.x/script/IfElseTest.gsql | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 demos/guru_scripts/docker/tutorial/4.x/script/IfElseTest.gsql diff --git a/demos/guru_scripts/docker/tutorial/4.x/script/IfElseTest.gsql b/demos/guru_scripts/docker/tutorial/4.x/script/IfElseTest.gsql new file mode 100644 index 00000000..29292cdb --- /dev/null +++ b/demos/guru_scripts/docker/tutorial/4.x/script/IfElseTest.gsql @@ -0,0 +1,35 @@ +USE GRAPH financialGraph +CREATE OR REPLACE QUERY IfElseTest () SYNTAX V3 { + + SumAccum @@isBlocked; + SumAccum @@unBlocked; + SumAccum @@others; + + S1 = SELECT a + FROM (a:Account) + ACCUM + IF a.isBlocked THEN @@isBlocked += 1 + ELSE IF NOT a.isBlocked THEN @@unBlocked += 1 + ELSE @@others += 1 + END; + + PRINT @@isBlocked, @@unBlocked, @@others; + + STRING drink = "Juice"; + SumAccum @@calories = 0; + + //if-else. Top-statement level. Each statement + //needs to end by a semicolon, including the “END”. + + IF drink == "Juice" THEN @@calories += 50; + ELSE IF drink == "Soda" THEN @@calories += 120; + ELSE @@calories = 0; // Optional else-clause + END; + // Since drink = "Juice", 50 will be added to calories + + PRINT @@calories; +} + +INSTALL QUERY IfElseTest + +RUN QUERY IfElseTest()