First of all, I'm a newbie in programming, so sorry if I'm making syntax mistakes or asking silly questions. I want to loop a query (the query itself is working) in HSQL and I tried it with a WHILE statement, with an IF statement,... but non of them is working. The idea is that I want to use a value in a table generated by my query and use that value in the following WHERE statement of (select, from, where) untill that value IS NULL. What I'm doing wrong? Already in the declaration of the variables? In the code I left some code out from the SELECT/FROM statement, since that statement is working when not 'looped'.
CREATE PROCEDURE (a)
BEGIN ATOMIC
DECLARE input INTEGER;
SET input = 49;
WHILE input = NOT NULL
DO
SELECT "SampleID"."Sample ID", "SampleID"."Originating from SampleID", "SampleID"."Info" "ProjectID"."ProjectName"
FROM { oj "SampleID" LEFT OUTER JOIN "ProjectID" ON "SampleID"."ProjectID" = "ProjectID"."ProjectID"
WHERE ( "SampleID"."Sample ID" = input);
SET input= ("SampleID"."Originating from SampleID")
END WHILE;
END