Is it possible to bind a value for ISDESCENDANTNODE in a SQL2 query? | Community
Skip to main content
LinearGradient
Level 6
October 16, 2015
Solved

Is it possible to bind a value for ISDESCENDANTNODE in a SQL2 query?

  • October 16, 2015
  • 3 replies
  • 1478 views

Hi,

Neither of these queries compile:

SELECT * FROM [cq:PageContent] AS n WHERE ISDESCENDANTNODE(n, [$sitePath])

SELECT * FROM [cq:PageContent] AS n WHERE ISDESCENDANTNODE(n, $sitePath)

Am I missing something here?

Thanks.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Mshaji

This statement is a string, you may have to perform string operations

statement =" SELECT * FROM [cq:PageContent] AS n WHERE ISDESCENDANTNODE(n, " + $sitePath + ")";

you need to replace $sitePath with your variable.

3 replies

MshajiCommunity AdvisorAccepted solution
Community Advisor
October 16, 2015

This statement is a string, you may have to perform string operations

statement =" SELECT * FROM [cq:PageContent] AS n WHERE ISDESCENDANTNODE(n, " + $sitePath + ")";

you need to replace $sitePath with your variable.

Community Advisor
October 16, 2015

Maybe you can do like this

String expression = "SELECT * FROM [cq:PageContent] AS n WHERE ISDESCENDANTNODE(n, $sitePath)";  // as aboveString sitePath= ...QueryManager queryMgr = session.getWorkspace().getQueryManager();Query query = queryMgr.createQuery(expression,Query.JCR_SQL2);query.bindValue("sitePath",sitePath);QueryResult result = query.execute();
smacdonald2008
Level 10
October 16, 2015