Hi there!
Lately, I've been playing with OrientDB of 1.7.10 and now 2.0.1. And currently I am stuck with poor SQL syntax or my misunderstanding of it.
What I want is to create an instance of a class if it does not exist. I tried different solutions, like `ifnull`, `first` and `if`. But it seems to work only on existing values.
For example, let us have a class `City` with only one instance - `{"name": "Lisboa"}`.
These do not work:
select if(count(select City where name = "Krakow") < 1, null, (insert into City set name = "Krakow" return @rid))
select ifnull((select @rid from City where name = "Krakow"), (insert into City set name = "Krakow" return @rid))
select first((select @rid from City where name = "Krakow"), (insert into City set name = "Krakow"))
I believe I need some kind of `exists` operator:
select if( exists(select from City where name = "Krakow"), (select @rid from City where name = "Krakow"), (insert into City set name = "Krakow"))
Are there any possibility for this except stored functions?
Thanks!