on 05-15-2018 5:18 PM
Hi All,
I want to write an impex which should remove all the row which is not matched with a column value.
Example: I want to remove all the rows which are not having a value as USD in the p_isocode column in currency table.
Any help is much appreciated.
Thanks and Regards, Ansell
You can try the following tested ImpEx:
$dburl=jdbc:mysql://localhost/hybris67
$dbusername=hybris67
$dbpassword=hybris67
$dbdriver=com.mysql.jdbc.Driver
REMOVE Currency[batchmode=true];pk[unique=true];
#% impex.initDatabase("$dburl", "$dbusername","$dbpassword","$dbdriver");
"#%
impex.includeSQLData(
""SELECT PK FROM currencies WHERE p_isocode <>'USD'""
);
"
Notes:
Please replace the DB connection parameters as per your application.
I am assuming that USD
is your Base currency. If USD
is not your Base currency, the ImpEx mentioned above will remove all the currencies except USD
and your Base currency; but you will also get an exception because of RemoveBaseCurrencyInterceptor
.
I would go with Andrew's approach but I have answered it just because you have mentioned that you want to do it using ImpEx.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Not with impex but you could with a small amount of Groovy scripting
flexibleSearchService.search(/select {pk} from {currency} where {isocode}<>'USD'/).result.each {
modelService.remove it
}
Just make sure you've set the ROLLBACK slider to COMMIT
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
5 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.