Stored query vars not bound with BIND

I am trying to create a unique label for instances of a certain type by binding one of the strings returned by a stored query. The query looks something like this:

SELECT ?my_label ?record_label ?my_label_extended ?my_record_extended ?my_label_record
WHERE {
    SERVICE <query://my-query> { 
            [] sqs:vars ?my_label, ?my_table
            }
    GRAPH <virtual://my-database> {
          ?record a ?my_table ;
                rdfs:label ?record_label .
          BIND (CONCAT(STR(?my_label), "-Record-") AS ?my_label_extended)
          BIND (CONCAT("Record-", STR(?record_label)) AS ?my_record_extended)
          BIND (CONCAT(STR(?my_label), "-Record-", STR(?record_label)) AS ?my_label_record)
    }
}

The results will bind the values for ?my_label, ?record_label, and ?my_record_extended but not ?my_label_extended or my_label_record. So it looks like there is some issue using BIND with sqs:vars.

Placing the CONCAT directly in the SELECT as a variable works to overcome this, but I am trying to return this label in a CONSTRUCT query so I believe using BIND is the correct/only option.

Any thoughts on what might be going on here?

Hi Nolan,

Can you show the query plan? It kind of looks like that your BIND statements should be outside of the GRAPH <virtual://my-database> {..} block, otherwise the SQS variables aren't bound when those BINDs are evaluated.

Cheers,
Pavel

Hi Pavel,

Thanks! I took a look at the query plan and the problem variables were not present. I tried your suggestion and moved the BIND to the outer scope and that solved the issue =)

Cheers,

Nolan

1 Like

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