Re: [GENERAL] Procedural Languages

2012-05-31 Thread Mike Toews
On 1 June 2012 02:36, John Townsend wrote: > There are least 10 Procedural Languages available for PostGreSQL. The one > that comes with the installation is PL/pgSQL. The count looks closer to 18 http://en.wikipedia.org/wiki/PostgreSQL#Procedural_languages but I doubt some get much use (PL/LOLCOD

[GENERAL] Deferrable constraint checking with SAVEPOINT?

2010-06-07 Thread Mike Toews
Hi, I have a question that is not specified in the docs[1]. I am using deferrable constraints in a transaction with SET CONSTRAINTS ALL DEFERRED. Now I know that DEFERRED constraints are not checked until transaction COMMIT (i.e., the end), however are they checked with SAVEPOINT (i.e., part-way i

Re: [GENERAL] Converting time interval to double precision of time unit

2010-03-30 Thread Mike Toews
On 30 March 2010 11:55, Tom Lane wrote: > I think what Mike is actually looking for is > > SELECT extract(epoch from interval '3 days 2 hours 34 minutes'); >  date_part > --- >    268440 Yet better, if I define 1 hour as 3600 seconds (this is only incorrect if the interval spans over a le

[GENERAL] Converting time interval to double precision of time unit

2010-03-30 Thread Mike Toews
I'm using 8.3, and I'm trying to work with the interval type, and I can't seem to get things right. I've been all over the docs[1,2], and there is no mention on how this can be done. While I can get: SELECT '3 day 2 hour 34 minute'::interval .. how can then get the fractional hours of this time i

Re: [GENERAL] PL/Python debugging - line numbers

2009-07-15 Thread Mike Toews
ment\n',) The actual error is on line 8 (not 9), which is a bit odd. Perhaps there is a "import plpy" inserted somewhere internally. I noticed that the messages through PL/Python are all tuples with length 1, like this: ("my message",). Why? This doesn't print to

[GENERAL] PL/Python debugging - line numbers

2009-07-14 Thread Mike Toews
Hi, Debugging PL/Python isn't as easy as with PL/pgSQL, as it appears I can't see line numbers where errors occur. For example: ERROR: plpython: function "evaluate_something" failed DETAIL: : sequence index must be integer, not 'str' The location of this type of exception is difficult to

Re: [GENERAL] Select ranges based on sequential breaks

2009-06-22 Thread Mike Toews
Scott Marlowe wrote: On Mon, Jun 15, 2009 at 12:23 PM, Mike Toews wrote: This is easy to compute using a spreadsheet or in R, but how would I do this with SQL? I'm using 8.3. Advice is appreciated. FYI (and I'm no expert in this area) R is available as a pl for postgres, loo

Re: [GENERAL] Select ranges based on sequential breaks

2009-06-22 Thread Mike Toews
Hi Joel, Window functions appear to be the best solution for this style of problem, and I'm looking forward to their applications. However, I'm sticking with 8.3 for at least a year, so I'm not able to explore this solution yet. For now, I can only post-process the output in a non-SQL environ

[GENERAL] Select ranges based on sequential breaks

2009-06-15 Thread Mike Toews
Hi, I'm having difficulty constructing a query that will find breaks where data change in a time-series. I've done some searching for this too, but I haven't found anything. Here is my example situation, consider my source table: datebin 2009-01-01 red 2009-01-02 red 2009-01-03

Re: [GENERAL] Specifying text to substitute for NULLs in selects

2008-11-07 Thread Mike Toews
Mike Toews wrote: Keep in mind that you can't mix data types, like 'NaN'::text and 32.3::float in the result. oh yeah, regarding mixing data types (in regards to the first post)... A good exception is that you can use 'NaN' for floating point data types, so: SE

Re: [GENERAL] Specifying text to substitute for NULLs in selects

2008-11-07 Thread Mike Toews
Said Ramirez wrote: I think you are more after something like SELECT CASE WHEN foo IS NULL THEN 'NA' END FROM bar. -Said An even simpler way to do this is using the COALESCE function: http://www.postgresql.org/docs/current/interactive/functions-conditional.html SELECT COALESCE(foo, 'NA') AS

Re: [GENERAL] Quiet "CONTEXT"?

2008-10-28 Thread Mike Toews
Tom Lane wrote: In psql, "\set VERBOSITY terse" might approximate what you want. This works perfectly in psql (exactly what I wanted). However, I'm most comfortable using PgAdminIII, and I've tried adding "SET VERBOSITY TO terse;" to either the first command or within the PL/pgSQL function

[GENERAL] Quiet "CONTEXT"?

2008-10-28 Thread Mike Toews
Hi all, I'm in the process of debugging some PL/pgSQL functions. I have function A which calls function B (e.g. on Line 22). The debugging info I'm interested in is in function B, but I call function A (since there are other C, D, F functions called from A). However, what I see is really dist