• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Deriving string attributes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Deriving string attributes


  • Subject: Re: Deriving string attributes
  • From: Mark Ritchie <email@hidden>
  • Date: Thu, 13 Jan 2005 16:08:42 -0500

On Jan 13, 2005, at 12:06 PM, Florijan Stamenkovic wrote:
I want to derive a string from two other attributes and put in a " " or some other string like " has " in between. It has to be done in SQL. How do I do that?

The following applies to Oracle. You may have to adjust it to work for other databases.
The concatenate operator is two vertical bars and is used like this:
column1 || column2


This will concatenate the values from each column. If you want a space between the values from each column, then you need to use something like:
column1 || ' ' || column2


However, please remember that this will blindly concatenate values.
You may not get what you want when there are missing values from one or more of the columns.


I've included a sample session from Oracle below.

Oh and just for interest, you can include the SQL directly into your EOModel using the derived attribute feature. That way, the SQL can be fetched from the database on the fly when the EO is fetched.

Good luck!
Mark.


SQL> desc employee;
Name Null? Type
----------------------------------------- -------- ----------------------------
EMPLOYEE_ID NUMBER
NAME VARCHAR2(20)
JOB VARCHAR2(20)
MANAGER NUMBER
SALARY NUMBER
COMMISION NUMBER
DEPARTMENT_ID NUMBER


SQL> select name, job from employee;

NAME                 JOB
-------------------- --------------------
King                 President
Blake                Manager
Clark                Manager
Martin               Saleman

SQL> select name || ' ' || job from employee;

NAME||''||JOB
-----------------------------------------
King President
Blake Manager
Clark Manager
Martin Saleman

__
Mark Ritchie, email@hidden 416-843-5479
Software Developer, Apple Certified Developer Trainer
WebObjects, Cocoa, Mac OS X and Mac OS X Server
Diamond Lake Consulting Inc., Toronto, Ontario, Canada

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


References: 
 >Deriving string attributes (From: Florijan Stamenkovic <email@hidden>)

  • Prev by Date: Re: Modifying userPresentableDescription in D2W
  • Next by Date: Image display in D2W componets
  • Previous by thread: Re: Deriving string attributes
  • Next by thread: WOUpload different behaviour on deployment
  • Index(es):
    • Date
    • Thread