Hi Chuck,

|| doesn't return anything in MySQL. Looks like Oracle uses "concat()" or "||".

Interesting. I actually had no idea that || was concat. You learn something every day :-)

Final derived attribute definition for MySQL: concat(coalesce(author,''), coalesce(title,''))

David

-- 

It's like driving a car at night. You never see further than your headlights, but you can make the whole trip that way. 


E. L. Doctorow


from Sunbeams: http://www.thesunmagazine.org 



On 17 Jul 2006, at 2:42 PM, Chuck Hill wrote:

CONCAT?  Is that from Oracle or MySQL?  || is the SQL92 operator for concatenation.  This is the weakness of this approach: it is not database agnostic.

The COALESCE substitutes the empty string for null.  Otherwise null || 'X' or 'X' || null results in null which is not what you wanted for your search.

Chuck


On Jul 17, 2006, at 2:36 PM, David Holt wrote:

Thanks for the reply Chuck. Your hint about using a derived column was really helpful. I defined it as CONCAT(author,title) which works as expected. I am not sure what the COALESCE function would give me?

David

On 17 Jul 2006, at 9:27 AM, Chuck Hill wrote:

I have never done this, but you should be able to set this up in EOModeler.  Add a new Attribute named  simpleSearch, make it Derived instead of Column.  Define it as
COALESCE( author, '') || COALESCE( title, '')
and mark it as read only.  You can get rid of the method below and your existing search should work.

Chuck


On Jul 14, 2006, at 5:03 PM, David Holt wrote:

I am using DisplayGroups which make queries on individual attributes very easy.

I would like to provide a simple search where one text field returns a search on a concatenation of several attributes of the entity. I just tried putting the following code in my EO to try this concept out (title and author are attributes in the entity):

public String simpleSearch() {
          String author = author();
String title = title();

String simpleSearch;


        if ((author != null) && (!author.equals(""))) {
            simpleSearch = author + " " + title;
        }
        else {
            simpleSearch = title;
        }


        return simpleSearch;
    }

When I try and do a queryMatch on the simpleSearch field I get an error:
java.lang.IllegalStateException: sqlStringForKeyValueQualifier: attempt to generate SQL for com.webobjects.eocontrol.EOKeyValueQualifier (simpleSearch caseinsensitivelike '*test*') failed because attribute identified by key 'simpleSearch' was not reachable from from entity 'Document'

I assume this is because the attribute "simpleSearch" is not actually in the database. Is there a better strategy for searching concatenated fields using DisplayGroups?

Thanks,
David


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:

This email sent to [EMAIL PROTECTED]

-- 
Coming sometime... - an introduction to web applications using WebObjects and Xcode     http://www.global-village.net/wointro

Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.    http://www.global-village.net/products/practical_webobjects






-- 
Coming sometime... - an introduction to web applications using WebObjects and Xcode     http://www.global-village.net/wointro

Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.    http://www.global-village.net/products/practical_webobjects





 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to