You can use regular expression to identify the property name from the query and then do a replace. The code would look something like this...
def query = "select name from subscribers where phonenb = NEW-CREATE.SUBS.phone and homeaddress = NEW-CREATE.SUBS.address"
def regExp = /NEW-CREATE.SUBS.([a-zA-Z]+)/
matcher = ( query =~ regExp )
matcher.each { match ->
def prop = testRunner.testCase.testSuite.project.getPropertyValue(match[1])
//update the query
query = query.replace("NEW-CREATE.SUBS." + match[1],prop)
}
log.info query
//returns
//Tue Apr 08 11:59:58 ADT 2014:INFO:select name from subscribers where phonenb = 999-999-9999 and homeaddress = nowhere to go
Alternate Solution, Using a prefix stored at project level. The project level property for holding the prefix is called prefix
def query = "select name from subscribers where phonenb = NEW-CREATE.SUBS.phone and homeaddress = NEW-CREATE.SUBS.address"
def prefix = context.expand('${#Project#prefix}') //get prefix from project level properties.
def regExp = /${prefix}([a-zA-Z]+)/
matcher = ( query =~ regExp )
matcher.each { match ->
def prop = testRunner.testCase.testSuite.project.getPropertyValue(match[1])
//update the query
query = query.replace(prefix + match[1],prop)
}
log.info query
//returns
//Tue Apr 08 15:20:51 ADT 2014:INFO:select name from subscribers where phonenb = 999-999-9999 and homeaddress = nowhere to go