I have the following error:
Error> [TQL03] TypeQL Error: There is a syntax error at line 11:
delete $connectsTo1 isa connectsTo;
^
extraneous input 'delete' expecting {, 'match', 'define', 'undefine', 'insert'}
I have the following query:
match
$sensor isa Sensor, has id $sensorID;
$segment1 isa Segment, has id $segment1ID;
$segment3 isa Segment, has id $segment3ID;
not { $segment1 is $segment3; };
$monitoredBy1(TrackElement: $segment1, Sensor: $sensor) isa monitoredBy;
$monitoredBy2(TrackElement: $segment3, Sensor: $sensor) isa monitoredBy;
$connectsTo1(TrackElement: $segment1, TrackElement: $segment3) isa connectsTo;
get $segment1ID, $segment3ID;
limit 1;
delete $connectsTo1 isa connectsTo;
insert $segment2 isa Segment, has id 555555;
insert $connectsTo2(TrackElement: $segment1, TrackElement: $segment2) isa connectsTo;
insert $connectsTo3(TrackElement: $segment2, TrackElement: $segment3) isa connectsTo;
insert $monitoredBy3(TrackElement: $segment2, Sensor: $sensor) isa monitoredBy;
This query should find a random instance of two segments that are monitored by the same sensor and they are connected to each other. Then delete the connection between them, create a new segment which wedges in between them and monitored by the same sensor.
I tried to run the query without the delete line. After that the first insert line was succesfull, but with the second insert line i got this error: ## Error>[THW15] Invalid Thing Write: The thing variable '$segment1' cannot be inserted as a new instance without providing its type (isa). It seems like the query doesn't recognises $segment1 anymore.
The
getclause makes it thematchquery. TypeDB Studio just executes these lines as multiple queries. Anddeletequery can't be without amatchclause.If you delete the
deleteclause it will still see multiple queries -matchquery (withmatchandgetclauses) and theninsertquery (which can be without amatchclause, but it's lacking the variable bounding in this particular case).I would suggest deleting the
getclause. Then it should see theupdate(ormatch-delete-insert) query. Alternatively, you can try splitting these into multiple queries withmatchclauses for every query.P.S. TypeDB language-specific libraries won't have this problem as in them you manually send each query and even select its type (every query type has a separate method to send the query).
P.P.S. Oh, and those insert keywords at the end - they are also creating separate queries (at least the TypeDB Studio treats them like that). If your intent was to send all these as a single query - drop the duplicate inserts. Only the first one should be sufficient.