NexusDB declare and set table result in a variable and select it

210 views Asked by At

In NexusDB I'm trying to create add a query result in a variable, then update the selected items and later select the variable

START TRANSACTION;
    set result = (SELECT * FROM "some_table" where synced = false);
    UPDATE some_table set synced = true where synced = false;
    select result;
COMMIT;

NexusDB: Query78696906: Query execution failed: Error in statement: Unable to resolve the identifier "result" at line 4, pos 12

Answer:

 SELECT * INTO #tmp from some_table where synced is null;
 UPDATE some_table set synced = true where synced is null;
 select * #tmp;
1

There are 1 answers

0
NexusDB Expert On BEST ANSWER

"select result" is a syntax error. NexusDB expects you to select from something; in this case, you can use the built-in #dummy table that is there for this exact purpose. So:

SELECT result FROM #dummy