Re: find earliest, by date, record in a table?
Re: find earliest, by date, record in a table?
- Subject: Re: find earliest, by date, record in a table?
- From: Baiss Eric Magnusson <email@hidden>
- Date: Tue, 17 Aug 2010 14:23:27 -0700
Wonder -> "Nice, nice, nice, all those people in the same device" Kurt Vonnegut.
EOQualifier qualifier = new EOKeyValueQualifier( "owner", EOQualifier.QualifierOperatorEqual, dbOwner() );
NSTimestamp timeEarliest = ERXEOControlUtilities.aggregateTimestampWithQualifier( ec, "Transaction", "date", "min", qualifier );
earliestTrans = (Transaction)EOUtilities.objectMatchingKeyAndValue( ec, "Transaction", "date", timeEarliest );
The <EOUtilities.objectMatchingKeyAndValue> on a NSTimestamp is a bit unnerving, but it worked.
This is new territory resulting from the batching of a bank's XML/OFX type files, I needed to know when to start the monthly balance forwarding.
Thanks,
Baiss
On Aug 17, 2010, at 9:38 AM, Hugi Thordarson wrote:
> Hi Baiss.
>
> If you're using Wonder:
> NSTimestamp t = ERXEOControlUtilities.aggregateTimestampWithQualifier( ec, "TheEntityName", "theAttributeName", "min", null );
>
> If you're using plain ol' WO:
> NSArray<NSDictionary<String,NSTimestamp>> a = EOUtilities.rawRowsForSQL( ec, "TheEOModelName", "select min(THE_COLUMN_NAME) from THE_TABLE_NAME", new NSArray<String>( "someKey" ) );
> NSTimestamp t = a.objectAtIndex( 0 ).objectForKey( "someKey" );
>
> If you're lucky, you might be able to just create a regular fetch specification and setFetchLimit( 1 ). For some DBs, this will generate an SQL statement with LIMIT, but unfortunately I have no idea which WO DB Plugins support this. You can try it though.
>
> - hugi
>
>
> On 17.8.2010, at 15:25, Baiss Eric Magnusson wrote:
>
>> Does anyone know a SQL EOUtilities generation that would yield the earliest record.
>>
>> How can I create a search criteria that will return the earliest record in a table ( the records are time stamped with a date, not the creation date but the occurrence date ), without returning a sort of all the records in the table?
----
Baiss Eric Magnusson
CascadeWebDesign.com
_______________________________________________
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