Expand my Community achievements bar.

SOLVED

SQL2 Update Query

Avatar

Level 5

I'm using AEM 6.2.

Is it possible to update content using a SQL2 query with the Tools, Query, SQL2 tool?

Example Select

select * from [nt:unstructured] as p where isdescendantnode (p, [/content/]) AND [sling:resourceType] like '/apps/project/component%'

and Update the content to '/apps/project/component2'

Thank you in advance for your help.

-Dean

1 Accepted Solution

Avatar

Correct answer by
Level 3

From description - no.

One more option is a bulk editor

https://docs.adobe.com/docs/en/aem/6-1/administer/operations/bulk-editor.html

  1. Make a query
  2. Export results to excel file
  3. Filter/update properties in excel file
  4. Import excel file

But, be aware. From documentation: 

When you re-import content, you erase any previous content for those nodes. Be careful not to overwrite important information.

View solution in original post

8 Replies

Avatar

Level 10

Yes - when using JCR SQL2 - you get back a result set of nodes. You can then update the nodes using JCR API.

Invoke the node's setProperty method to modify the values.  

Avatar

Level 5

Can you do it within the query?

Similar to SQL ... UPDATE XXX where ...

Do I have to use JCR API?

-Dean

Avatar

Level 5

This is a GREAT tool.  Do you happen to know if I can update ANY/all properties within a given path?

Example:

Path:  /content/project/subproject

reference property: sling:resourceType

reference property value: foundation/components/reference

property:  jcr:title

new value:  This is the new value

I'm trying to find all of the sling:resourceType='foundation/components/reference' with a property of jcr:title and update the jcr:title to 'This is a new value'

Thanks,

-Dean

Avatar

Correct answer by
Level 3

From description - no.

One more option is a bulk editor

https://docs.adobe.com/docs/en/aem/6-1/administer/operations/bulk-editor.html

  1. Make a query
  2. Export results to excel file
  3. Filter/update properties in excel file
  4. Import excel file

But, be aware. From documentation: 

When you re-import content, you erase any previous content for those nodes. Be careful not to overwrite important information.

Avatar

Level 9

As per Sling Query documentation, updating directly from query isn't available as of now.

https://github.com/Cognifide/Sling-Query/wiki/Method-list

deana66659071 wrote...

I'm using AEM 6.2.

Is it possible to update content using a SQL2 query with the Tools, Query, SQL2 tool?

Example Select

select * from [nt:unstructured] as p where isdescendantnode (p, [/content/]) AND [sling:resourceType] like '/apps/project/component%'

and Update the content to '/apps/project/component2'

Thank you in advance for your help.

-Dean

 

Avatar

Level 5

~~Anton Smulskiy ...

This is probably the best approach for what we're looking for.

Thanks to all for your responses.

-Dean