Re: [SQL] How to access multicolumn function results?

2013-01-23 Thread Tom Lane
Andreas writes: > SELECT some_fct( some_id ) FROM some_other_table; > How can I split this up to look like a normal table or view with the > column names that are defined in the RETURNS TABLE ( ... ) expression of > the function. The easy way is SELECT (some_fct(some_id)).* FROM some_o

[SQL] How to access multicolumn function results?

2013-01-23 Thread Andreas
Hi I've got functions that return a TABLE. If I call it with constant parameters like: SELECT * FROM some_fct( 42 ); I get a table with column names as the result as intended. When I rather call it with the parameter coming from another table I get a set of records where I don't know how to a

Re: [SQL] Problem with extract(epoch from interval ...

2013-01-23 Thread Adrian Klaver
On 01/23/2013 03:00 AM, Ian Lawrence Barwick wrote: Hi 2013/1/23 Kaloyan Iliev : Hi, I have a little problem with extract epoch from interval. It seems that the query works if the interval is in a string but not from DB field. Could someone provide support. (...) You have a casting error; ins

Re: [SQL] Re: [SQL] need some magic with generate_series()

2013-01-23 Thread Andreas
I'm sorry to prove that daft. :( generate_series needs the startdate of every project to generate the specific list of monthnumbers for every project. To join against this the list needs to have a column with the project_id. So I get something like this but still I cant reference the columns

Re: [SQL] Problem with extract(epoch from interval ...

2013-01-23 Thread Kaloyan Iliev
Thanks, It works perfectly. Regards, Kaloyan Iliev On 23.01.13 13:00, Ian Lawrence Barwick wrote: Hi 2013/1/23 Kaloyan Iliev : Hi, I have a little problem with extract epoch from interval. It seems that the query works if the interval is in a string but not from DB field. Could someone provid

Re: [SQL] Problem with extract(epoch from interval ...

2013-01-23 Thread Ian Lawrence Barwick
Hi 2013/1/23 Kaloyan Iliev : > Hi, > I have a little problem with extract epoch from interval. It seems that the > query works if the interval is in a string but not from DB field. > Could someone provide support. (...) You have a casting error; instead of: > dbr=# SELECT extract(EPOCH FROM INT

[SQL] Problem with extract(epoch from interval ...

2013-01-23 Thread Kaloyan Iliev
Hi, I have a little problem with extract epoch from interval. It seems that the query works if the interval is in a string but not from DB field. Could someone provide support. Thanks in advance. Best regards, Kaloyan Iliev db=# begin; BEGIN db=# SELECT version(); version

[SQL] Range types (DATERANGE, TSTZRANGE) in a foreign key with "inclusion" logic

2013-01-23 Thread Matthias Nagel
Hello everybody, first a big thank you to all that make the range types possible. They are great, especially if one runs a database to manage a student's university dormitory with a lot of temporal information like rental agreements, room allocations, etc. At the moment we are redesigning our d

[SQL] vacuum / analyze parent tables on partitioned tables.

2013-01-23 Thread Bert
Hello, I wrote a script to make sure all tables are vacuumed and analyzed every evening. This works very well, but I have a question: I save in a table the start and end time of a vacuum/analyze. This way I can measure what tables take a long time to vaccum/analyze, and what tables are slow. (and