• 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: help needed with query
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: help needed with query


  • Subject: Re: help needed with query
  • From: "Jerry W. Walker" <email@hidden>
  • Date: Mon, 4 Feb 2008 13:02:24 -0500

Hi, Ted,

I'm sorry I didn't respond in time to help with your original question. However, you still might find the following two references helpful if you're new to the "WO Way" of dealing with a database:

http://wiki.objectstyle.org/confluence/display/WO/EOF-Using+EOF- Overview

http://wiki.objectstyle.org/confluence/display/WO/EOF-Using+EOF- Raw+Rows

HTH.

Regards,
Jerry

On Feb 4, 2008, at 11:07 AM, Theodore Petrosky wrote:

Thanks for the replies...  yes I did not want to send
raw SQL... I didn't realize that I could create a
FetchSpecification that did what I needed... I already
had the relation set up, so that was all I was missing
was the part about where to create this fetchSpec...

It's working fine now. Thanks everyone...

Ted


--- Don Lindsay <email@hidden> wrote:

Looks like you are working too hard. :)  WebObjects
does many things
for you, if you are expending a lot of effort to
accomplish
something, it is probably can be done simpler using
WebObjects.

You can run a query directly, but I would recommend
using a fetch
specification to retrieve the records from the
editing context and
not running a query.  At least then your objects are
up to date with
the database and are refreshed as needed by the EOF.

But if you really really really really really want
to write a
passthough SQL in WebObjects, I wouldn't recommend
it, here is the code:

		String sqlString = "SELECT * FROM USERS";
		try {
			NSArray oResult =
EOUtilities.rawRowsForSQL(session

().defaultEditingContext(),"EOMODELNAMEGOESHERE",sqlString);
		} catch (Exception e) {
                         //oops error occurred.
		}

Thanks,

Don

On Feb 4, 2008, at 8:57 AM, Theodore Petrosky wrote:

First, most of my experience is with cocoa. I
could
write any query I wanted even across
relationships. I
am having a problem with relationship in WO.

I am starting out with a new simple setup. My db
is
normalized like this

table names:
firstname text
lastname text
nameid (serial)

namesbusinessmeta:
iscurrent bool  default true
phonenumber text
extension text
nbmid
namesFKid foreign key to names

I have a trigger and function on the db that
creates a
new insert into namesbusinessmeta with the
referenced
foreign key on insert into the names table.

This works fine.

but now I want to query from my WO app.
select * from names where nameid in (select
namesFKid
from namesbusinessmeta where iscurrent = true)
order
by lastname;

I am lost.... I want an array of current employees
where the iscurrent  bool is in relationship
table.

Maybe I am barking up the wrong tree......

Ted


--
__ Jerry W. Walker,
WebObjects Developer/Instructor for High Performance Industrial Strength Internet Enabled Systems


    email@hidden
    203 278-4085        office



_______________________________________________
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: 
 >Re: help needed with query (From: Theodore Petrosky <email@hidden>)

  • Prev by Date: Re: Resizing images
  • Next by Date: Re: Resizing images
  • Previous by thread: Re: help needed with query
  • Next by thread: AW: help needed with query
  • Index(es):
    • Date
    • Thread