Re: [SQL] CTE or Subselect and outer joins not behaving as expected?

2011-10-25 Thread Harald Fuchs
In article , Joel Stevenson writes: > select tally_table. tally_mon, met.datum > from ( > select distinct date_trunc( 'month', '2011-06-01'::date + tally_day )::date > as tally_mon > from generate_series( 0, ( select current_date - '2011-06-01'::date ) ) as > tally_day > ) as tally_table fu

Re: [SQL] How to write sql to access another odbc source.

2011-10-25 Thread Craig Ringer
On 19/10/11 22:08, Rich wrote: > I have a mumps database with an ODBC connection so I can write queries > from other databases. How can I write a sql in Postgresql to access > this table to use in my Postgresql reports? Use dbi-link to make an ODBC connection to the other database. Either copy th

Re: [SQL] advice on how to store variable attributes

2011-10-25 Thread David Johnston
On Oct 22, 2011, at 10:07, Pavel Stehule wrote: > 2011/10/22 David Johnston : >> On Oct 22, 2011, at 6:41, Linos wrote: >> >>> Hi all, >>>i need a little of advice on what could be the best way to store this >>> information. >>> >>> We need to calculate the difference in costs for our oper

[SQL] Question about Escaping text when calling pgplsql functions

2011-10-25 Thread Matthias Howell
I have a situation where data in a text column contains line breaks of the form \r\n if I run a select such as select count(1) from table where wordcol = 'word1\r\nword2' I get 0. Same if I run select count(1) from table where wordcol = 'word1\nword2'. I get values if I run select count(1) from

[SQL] How to write sql to access another odbc source.

2011-10-25 Thread Rich
I have a mumps database with an ODBC connection so I can write queries from other databases. How can I write a sql in Postgresql to access this table to use in my Postgresql reports?

Re: [SQL] Problem with DROP ROLE

2011-10-25 Thread Andreas Kretschmer
You can't do that in THAT way, but you can use dynamic SQL:   test=# select * from drop_role ;    t  foobar (1 row) test=*# do $$ declare r text; begin for r in select t from drop_role loop execute 'drop role ' || quote_ident(r) || ';'; end loop; end; $$language plpgsql;   DO      "Bric

Re: [SQL] Handling mutliple clients access with views

2011-10-25 Thread Brice André
Thanks very much for those info. >From what I read, I think Veil will do the trick. I already use ROLES, but there are a few probems with them : - first, as I mix the data from different users in the same table, ROLES do not solve the complete problem. - second, this forces me to use a dedi