cancel
Showing results for 
Search instead for 
Did you mean: 

update the media.itemtype

Former Member
0 Kudos

Hi,

We have pdf documents in the media table. The itemtype is 'media' but should be of type 'MyMedia'. We use this special type as a marker.

An sql update statement would look like this:

 update media set itemtype = 'MyMedia'
 where itemtype = 'Media'
 and mime = 'appication/pdf'

  • Can we do this with impex directly?

  • Can we do this with an sql update statement on the running system?

Accepted Solutions (0)

Answers (1)

Answers (1)

andyfletcher
Active Contributor
0 Kudos

Can we do this with impex directly?

Unfortunately no you can't because you specify the unique columns to search on via impex which means you can't change those columns in the same line.

Can we do this with an sql update statement on the running system?

Not against a 'running' system but this sql would probably work whilst Hybris is shutdown. I'd definitely test this in a non live installation first!

update medias set typepkstring=(select pk from composedtypes where internalcode='MyMedia')
where typepkstring=(select pk from composedtypes where internalcode='Media')
and mime='application/pdf'

A potentially safer option would be to write some beanshell or groovy script to run via the hac that uses flexible search to retrieve all of the medias that you want to change and then loops over them changing and saving them.