How to Upsert like other NOSQL db with SPARQL?

like this query, i want to make a skos:broader between two concepts.
but one of them (the broader concept) may not exist, i want to create that broader concept URI with UUID() if its not there and its skosxl:Label, otherwise link them directly.

DELETE {
        :${conceptId} skos:broader ?broaderConceptId .
      }
      INSERT {
        :${conceptId} skos:broader ?broaderConceptId .
      }
      WHERE {
        OPTIONAL {
          ?broaderConceptId (skosxl:prefLabel|skosxl:altLabel|skosxl:hiddenLabel)/skosxl:literalForm "${broaderConceptLabel}" .
        }
      }

i've tried some thing like this, but failed

DELETE {
        :${conceptId} skos:broader ?broaderConceptId .
      }
      INSERT {
        :${conceptId} skos:broader ?broaderConceptId .
      }
      WHERE {
        BIND (
          COALESCE (
            IF ( exists { ?broaderConceptId (skosxl:prefLabel|skosxl:altLabel|skosxl:hiddenLabel)/skosxl:literalForm "${broaderConceptLabel}" . } ),
            BIND (UUID() as ?broaderConceptId)
          )
        ) AS ?broaderConceptId
      }
I20200715-14:34:44.453(8)? {
I20200715-14:34:44.453(8)?   status: 400,
I20200715-14:34:44.453(8)?   statusText: 'Bad Request',
I20200715-14:34:44.453(8)?   headers: Headers {
I20200715-14:34:44.453(8)?     _headers: {
I20200715-14:34:44.453(8)?       'content-encoding': [Array],
I20200715-14:34:44.453(8)?       connection: [Array],
I20200715-14:34:44.453(8)?       'sd-error-code': [Array],
I20200715-14:34:44.454(8)?       'content-type': [Array],
I20200715-14:34:44.454(8)?       date: [Array]
I20200715-14:34:44.454(8)?     }
I20200715-14:34:44.454(8)?   },
I20200715-14:34:44.454(8)?   ok: false,
I20200715-14:34:44.454(8)?   url: 'http://localhost:5820/app/update?reasoning=false',
I20200715-14:34:44.454(8)?   body: {
I20200715-14:34:44.454(8)?     message: 'com.complexible.stardog.plan.eval.ExecutionException: Encountered " ")" ") "" at line 11, column 126.\n' +
I20200715-14:34:44.454(8)?       'Was expecting one of:\n' +
I20200715-14:34:44.454(8)?       '    "," ...\n' +
I20200715-14:34:44.454(8)?       '    "=" ...\n' +
I20200715-14:34:44.454(8)?       '    "!=" ...\n' +
I20200715-14:34:44.454(8)?       '    ">" ...\n' +
I20200715-14:34:44.454(8)?       '    "<" ...\n' +
I20200715-14:34:44.454(8)?       '    "<=" ...\n' +
I20200715-14:34:44.454(8)?       '    ">=" ...\n' +
I20200715-14:34:44.454(8)?       '    "||" ...\n' +
I20200715-14:34:44.454(8)?       '    "&&" ...\n' +
I20200715-14:34:44.454(8)?       '    "+" ...\n' +
I20200715-14:34:44.455(8)?       '    "-" ...\n' +
I20200715-14:34:44.455(8)?       '    "*" ...\n' +
I20200715-14:34:44.455(8)?       '    "/" ...\n' +
I20200715-14:34:44.455(8)?       '    "in" ...\n' +
I20200715-14:34:44.455(8)?       '    "not in" ...\n' +
I20200715-14:34:44.455(8)?       '    <INTEGER_POSITIVE> ...\n' +
I20200715-14:34:44.455(8)?       '    <INTEGER_NEGATIVE> ...\n' +
I20200715-14:34:44.455(8)?       '    <DECIMAL_POSITIVE> ...\n' +
I20200715-14:34:44.455(8)?       '    <DECIMAL_NEGATIVE> ...\n' +
I20200715-14:34:44.455(8)?       '    <DOUBLE_POSITIVE> ...\n' +
I20200715-14:34:44.455(8)?       '    <DOUBLE_NEGATIVE> ...\n' +
I20200715-14:34:44.455(8)?       '    ',
I20200715-14:34:44.455(8)?     code: 'QE0PE2'
I20200715-14:34:44.455(8)?   }
I20200715-14:34:44.455(8)? }

this is working query

      INSERT {
        ?prefLabelId a skosxl:Label ;
          skosxl:literalForm "${broaderConceptLabel}".
        ?broaderConceptId skosxl:prefLabel ?prefLabelId .
        :${conceptId} skos:broader ?broaderConceptId .
      }
      WHERE {
        OPTIONAL {
          ?broaderConcept skosxl:prefLabel|skosxl:altLabel|skosxl:hiddenLabel ?prefLabel .
          ?prefLabel skosxl:literalForm "${broaderConceptLabel}"
        }
        BIND (
          IF (
            BOUND(?broaderConcept),
            ?broaderConcept,
            :${Random.id()}
          ) as ?broaderConceptId
        )
        BIND (
          IF (
            BOUND(?prefLabel),
            ?prefLabel,
            :${Random.id()}
          ) as ?prefLabelId
        )
      }

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.