Issue #2368: unclear syntax for update query

Type: DocumentationVersion: 2.7.5_05Priority: NormalStatus: FixedReplies: 5
#1

the syntax for selective update is unclear as the syntax in the documentation seems to be wrong. Query

Update Action Set transferred = 0
where a.objectsInCharge.nodePath like "/(PR)W4455NS01%" and
      a.objectsInCharge.nodePath like "%MARAS%"

results in

Query Execution Error
=====================
Unexpected query token 'a'
Update Action Set transferred = 0 where  ==> a <== .objectsInCharge.nodePath like "/(PR)W4455NS01%" and a.objectsInCharge.nodePath like "%MARAS%"

 

 

#2

It was a documentation error on the query update page. Thank you for your report.

It should be either with identification variable all the way:

  Query query = em.createQuery(
      "UPDATE Country c SET c.population = c.population * 11 / 10 " +
      "WHERE c.population < :p");
  int updateCount = query.setParameter(p, 100000).executeUpdate();

or with no identification variable at all:

  Query query = em.createQuery(
      "UPDATE Country SET population = population * 11 / 10 " +
      "WHERE population < :p");
  int updateCount = query.setParameter(p, 100000).executeUpdate();
ObjectDB Support
#3

it still does not work, using (directly in explorer)

Update Action a Set a.transferred = 0 where a.objectsInCharge.nodePath like "/(PR)W4455NS01%" and a.objectsInCharge.nodePath like "%MARAS%"

or

Update Action Set transferred = 0 where objectsInCharge.nodePath like "/(PR)W4455NS01%" and objectsInCharge.nodePath like "%MARAS%"

both result in:

Query Execution Error
=====================
null

#4

query

select a from  Action a where a.objectsInCharge.nodePath like "/(PR)W4455NS01%" and a.objectsInCharge.nodePath like "%MARAS%"

shows the expected results

 

#5

So probably there is a bug in addition to the documentation error. Moved to a new thread.

ObjectDB Support
#6

try that:

select a from  Action a where a.objectsInCharge.nodePath like "/(CR)70005%" and a.objectsInCharge.nodePath like "%(PR)70005%"

Update Action a Set a.transferred = 0 where a.objectsInCharge.nodePath like "/(CR)70005%" and a.objectsInCharge.nodePath like "%(PR)70005%"

 

 

Reply