Re: [SQL] Bit by commands ignored until end of transaction block again

2009-07-23 Thread Glenn Maynard
On Thu, Jul 23, 2009 at 1:31 AM, Richard Huxtond...@archonet.com wrote:  - Let me use SAVEPOINT outside of a transaction, You are never outside a transaction. All queries are executed within a transaction. Transaction block, then, if you insist. I think this is the root of your problem -

Re: [SQL] Bit by commands ignored until end of transaction block again

2009-07-23 Thread Richard Huxton
Glenn Maynard wrote: On Thu, Jul 23, 2009 at 1:31 AM, Richard Huxtond...@archonet.com wrote: - Let me use SAVEPOINT outside of a transaction, You are never outside a transaction. All queries are executed within a transaction. Transaction block, then, if you insist. I think this is the

Re: [SQL] Need magical advice for counting NOTHING

2009-07-23 Thread Shane Ambler
Andreas wrote: Hi, The source select counts log-events per user. All is well when a user has at least one event per log_type in the log within a given timespan. If one log_type is missing COUNT() has nothing to count and there is expectedly no result line that says 0. BUT I need this 0-line

Re: [SQL] Bit by commands ignored until end of transaction block again

2009-07-23 Thread Joshua Tolley
On Thu, Jul 23, 2009 at 02:04:53AM -0400, Glenn Maynard wrote: On Thu, Jul 23, 2009 at 1:31 AM, Richard Huxtond...@archonet.com wrote:  - Let me use SAVEPOINT outside of a transaction, You are never outside a transaction. All queries are executed within a transaction. Transaction

Re: [SQL] Need magical advice for counting NOTHING

2009-07-23 Thread A. Kretschmer
In response to Andreas : Hi, The source select counts log-events per user. All is well when a user has at least one event per log_type in the log within a given timespan. If one log_type is missing COUNT() has nothing to count and there is expectedly no result line that says 0. BUT I need

Re: [SQL] Bit by commands ignored until end of transaction block again

2009-07-23 Thread Chris
Joshua Tolley wrote: On Thu, Jul 23, 2009 at 02:04:53AM -0400, Glenn Maynard wrote: On Thu, Jul 23, 2009 at 1:31 AM, Richard Huxtond...@archonet.com wrote: - Let me use SAVEPOINT outside of a transaction, You are never outside a transaction. All queries are executed within a transaction.

Re: [SQL] Need magical advice for counting NOTHING

2009-07-23 Thread A. Kretschmer
In response to A. Kretschmer : test=*# select foo.user_name, foo.log_type, sum(case when log_type_fk is not null then 1 else 0 end) from (select user_id, user_name, log_type_id, log_type from users cross join log_type) foo full join log on ((foo.user_id, foo.log_type_id)=(log.user_fk,

Re: [SQL] Bit by commands ignored until end of transaction block again

2009-07-23 Thread Thomas Kellerer
Chris, 23.07.2009 09:06: psql -d dbname .. # select now(); now --- 2009-07-23 17:04:21.406424+10 (1 row) Time: 2.434 ms (csm...@[local]:5432) 17:04:21 [test] # savepoint xyz; ERROR: SAVEPOINT can only be used in transaction blocks

Re: [SQL] Bit by commands ignored until end of transaction block again

2009-07-23 Thread Richard Huxton
Glenn Maynard wrote: On Thu, Jul 23, 2009 at 2:41 AM, Richard Huxtond...@archonet.com wrote: Ah [cue light-bulb effect], I think I understand. Your function isn't in the database is it? Surely your application knows if it's issuing BEGIN..COMMIT? I'm writing a Python library call. It has no

Re: [SQL] Need magical advice for counting NOTHING

2009-07-23 Thread Glenn Maynard
On Thu, Jul 23, 2009 at 1:01 AM, Andreasmaps...@gmx.net wrote: SELECT user_name, log_type_fk, COUNT(log_type_fk) FROM log JOIN users ON (user_id = user_fk) WHERE (ts IS BETWEEN  sometime  AND   another) GROUP BY user_name, log_type_fk ORDER BY user_name, log_type_fk create table users

Re: [SQL] Bit by commands ignored until end of transaction block again

2009-07-23 Thread Stephen Frost
* Glenn Maynard (gl...@zewt.org) wrote: The ORM can't control transactions, can't call functions or can't set savepoints? It can't write the necessary SQL to say insert this unless it already exists, namely: If it can't cleanly handle failure cases like this one, then I think your issue

Re: [SQL] Bit by commands ignored until end of transaction block again

2009-07-23 Thread Adrian Klaver
On Thursday 23 July 2009 12:39:23 am Glenn Maynard wrote: The ORM on a whole is decent, but there are isolated areas where it's very braindamaged--this is one of them. They have a stable-release API-compatibility policy, which I think just gets them stuck with some really bad decisions for

[SQL] using count in other column

2009-07-23 Thread bartjoosen
Hi, I made up a query to make a count for each item for each month/year: SELECTArtnr_ID, to_char(Date_plan,) AS Jaar, to_char(Date_plan,MM) AS Maand, Count(tblArtnrs.Artikelnr) AS Monthly_count, val1,val2,val3 FROM ((tblAnalyses INNER JOIN tblStudies ON tblAnalyses.Studie_ID =