Look out for little Bobby Tables https://xkcd.com/327/
;-) On Sep 25, 2015, at 2:26 AM, Markus Ruggiero <mailingli...@kataputt.com> wrote: > Thanks for all your help. Here is the code I am using now (might need some > more error checking) > > Wish you all a WOnder-full day > ---markus--- > > public NSArray<Product> findProducts(EOEditingContext ec, String query, > NSArray<String> queryParameters) { > > String resolvedQuery = query; > for (String aParameter : queryParameters) { > resolvedQuery = query.replaceFirst( "\\?", aParameter ); > } > > EOEntity entity = ERXEOAccessUtilities.entityNamed(ec, > Product.ENTITY_NAME); > String modelName = entity.model().name(); > NSArray<NSDictionary> rows = EOUtilities.rawRowsForSQL( ec, > modelName, resolvedQuery, null ); > > NSMutableArray<String> productCodes = new > NSMutableArray<String>(); > for (NSDictionary dict : rows) { > NSArray<String> values = dict.allValues(); // there is > only one value in the dict, but we get an Array > String productCode = values.objectAtIndex( 0 ); > if (productCode != null) { > productCodes.addObject( productCode ); > } > } > > EOQualifier qualifier = > Product.ATTRIBUTE_PRODUCT_CODE_ERXKEY.in( productCodes ); > NSArray<Product> results = Product.fetchProducts( ec, > qualifier, null ); > return results; > } > > // Example query: > SELECT prod.PRODUCT_CODE FROM PRODUCT prod, SITE site, INDUSTRY_PRODUCT ipr, > INDUSTRY ind WHERE prod.SITE_ID = site.ID AND site.SITE_NAME = '?' AND > ipr.PRODUCT_ID = prod.ID AND ipr.INDUSTRY_ID = ind.ID AND ind.INDUSTRY_NAME > ='ANH' AND prod.PUB_TRIGGER = 'Y' AND ((prod.EXPIRATION_DATE > SYSDATE) OR > (prod.EXPIRATION_DATE IS NULL)); > > Some are a lot more complex with inner and outer joins and embedded SELECT > FROM ... WHERE .... IN .... > > > >> On 24.09.2015, at 16:22, Markus Ruggiero <mailingli...@kataputt.com> wrote: >> >> Folks, >> >> What is the preferred way to fetch EOs when you have a db vendor specific >> "select id from ... where ....." statement? >> >> I need to interface with a legacy system where I have to incorporate the >> functionality of an external java tool into a Wonder app. This external tool >> executes raw SQL select statements which it reads from a file. All the >> statements are in the form given above and return a list of primary key >> values (single column fortunately). The tool then iterates through that list >> and does whatever it has to do (issuing tons of more raw sql). My problem is >> that these select statements are rather complex and there are many of them. >> It is just not feasible to replace those with proper EOQualifiers. In >> addition these statements are parameterized with ? so they can be >> precompiled and then used with different query values. However everything >> can be done with standard EOs as soon as I have those corresponding to the >> returned list of ids. >> >> Thanks a lot >> ---markus--- >> _______________________________________________ >> Do not post admin requests to the list. They will be ignored. >> Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) >> Help/Unsubscribe/Update your Subscription: >> https://lists.apple.com/mailman/options/webobjects-dev/mailinglists%40kataputt.com >> >> This email sent to mailingli...@kataputt.com > > _______________________________________________ > Do not post admin requests to the list. They will be ignored. > Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) > Help/Unsubscribe/Update your Subscription: > https://lists.apple.com/mailman/options/webobjects-dev/rgurley%40smarthealth.com > > This email sent to rgur...@smarthealth.com
_______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com