Error in if condition in SQL Batch

Hi all,
I am trying to write a sql batch script in java.I am facing issue in comparing values in if condition.Attaching the following code:

begin;
LET SourceDataset = SELECT expand(out(“CatItemComponent_CatItemComponentCatalogueItem”)) from CatItemComponent where @rid = #24:102452;
LET TarDataset = SELECT expand(out(“CatItemComponent_CatItemComponentCatalogueItem”)) from CatItemComponent where @rid = #24:102453;
LET dataSetCount = SELECT out(“CatItemComponent_CatItemComponentCatalogueItem”).out(“IndirectEdge”).size() from CatItemComponent where @rid = #24:102452;
IF ($dataSetCount <= 0){
CREATE EDGE IndirectEdge FROM $SourceDataset To $TarDataset;
};
commit retry 10;

I am getting the following Exception: com.orientechnologies.orient.core.sql.executor.InternalResultSet cannot be cast to java.lang.Comparable.
Can someone please help ?
Also if possible any links to documentation for sql batch script examples in orientdb will be very helpful.
Thanks & Regards!

Hi @RearwardPine73

Try with the following:

LET dataSetCount = SELECT out(“CatItemComponent_CatItemComponentCatalogueItem”).out(“IndirectEdge”).size() as count from CatItemComponent where @rid = #24:102452;
IF ($dataSetCount[0].count <= 0){
  CREATE EDGE IndirectEdge FROM $SourceDataset To $TarDataset;
};

I hope it helps

Thanks

Luigi

1 Like