On Thu, Dec 23, 2010 at 5:58 PM, Oleg Broytman <[email protected]> wrote:
> .select().max() produces a simple query SELECT MAX(). If you need a
> query with a subquery you need to add the subquery explicitly using
> sqlbuilder.Select():
>
> serial = Path.select(
> Path.q.serial==Select('max(serial)', staticTables=['path']))
> return serial.getOne()
Thanks for your reply Oleg. I am sorry, but the above produces a bad query:
--
query = Sync.select(
AND(
Sync.q.syncpoint==self,
Sync.q.serial==sqlbuilder.Select(MAX('serial'),
Sync.q.syncpoint==self, staticTables=('sync',))
)
)
--
--
SELECT sync.id, sync.syncpoint_id, sync.serial, sync.stamp,
sync.status, sync.message FROM sync WHERE (((sync.syncpoint_id) = (1))
AND ((sync.serial) = (SELECT 'max(serial)' FROM sync WHERE
((sync.syncpoint_id) = (1)))));
--
As you can see, the 'max(serial)' ends up inside quotes within the
subselect. I can't find any MAX aggregate function to use in place of
the string...
Any additional hints?
------------------------------------------------------------------------------
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and,
should the need arise, upgrade to a full multi-node Oracle RAC database
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
sqlobject-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss