Error in Creation of Edges through SQL Batch

I want to create edges between the results of two queries.I tried several ways by using sub queries for e.g. CREATE EDGE E1 FROM (SELECT out('E1') FROM Countries where Id = '1' ) TO (SELECT out('E1') FROM Countries where Id = '9') but was getting following exception -"OCommandExecutionException.Invalid FROM VERTEX for EDGE DB NAME=“demo db” ".

I also tried the batch scripts in orient db studio with the following query:

begin LET FCo = SELECT out('E1') FROM Countries where Id = '1' LET TCo = SELECT out('E1') FROM Countries where Id = '9' FOR EACH($x in $FCo){ FOR EACH($y in $FCo){ CREATE EDGE E1 FROM $x.@rid TO $y.@rid } } commit retry 100
but I am still getting the following error-


Can someone please help?
Thanks.

Hi @RearwardPine73

The following should work (see the expand()):

CREATE EDGE E1 
FROM (SELECT expand(out('E1')) FROM Countries where Id = '1' ) 
TO (SELECT expand(out('E1')) FROM Countries where Id = '9') 

For the second script, you have to add a semicolon after the BEGIN and at the end of each statement

Thanks

Luigi

1 Like