Re: [SQL] Remote monitoring of Postgres w/minimal grants

2010-03-11 Thread Tony Wasson
On Wed, Mar 10, 2010 at 12:26 AM, Bryce Nesbitt wrote: > I'm setting up remote monitoring of postgres, but running into an > uncomfortable situation with permissions. > Basically it seems hard to set up a secure "read only" role, yet also allow > proper monitoring. > > A brief writeup of that is h

Re: [SQL] grouping/clustering query

2008-10-24 Thread Tony Wasson
On Fri, Oct 24, 2008 at 10:24 AM, Tony Wasson <[EMAIL PROTECTED]> wrote: > On Fri, Oct 24, 2008 at 8:04 AM, Steve Midgley <[EMAIL PROTECTED]> wrote: >> At 11:28 AM 10/23/2008, Joe wrote: >>> >>> Steve Midgley wrote: >>>>> >>>>> #

Re: [SQL] grouping/clustering query

2008-10-24 Thread Tony Wasson
On Fri, Oct 24, 2008 at 8:04 AM, Steve Midgley <[EMAIL PROTECTED]> wrote: > At 11:28 AM 10/23/2008, Joe wrote: >> >> Steve Midgley wrote: # (invoiceid, txid) (A, 1) (A, 3) (B, 1) (B, 2) (C, 5) (D, 6) (D, 7) (E, 8) (F, 8) For journalli

Re: [SQL] Can COPY update or skip existing records?

2008-10-01 Thread Tony Wasson
On Tue, Sep 30, 2008 at 5:16 AM, Glenn Gillen <[EMAIL PROTECTED]> wrote: > Hey all, > > I've got a table with a unique constraint across a few fields which I > need to regularly import a batch of data into. Is there a way to do it > with COPY without getting conflicts on the unique contraint? I hav

Re: [SQL] accounting schema

2008-02-07 Thread Tony Wasson
On Feb 6, 2008 6:08 PM, Medi Montaseri <[EMAIL PROTECTED]> wrote: > I am learning my way into Accounting and was wondering how Accounting > applications are designed. perhaps you could point the way > As a DBA, (and keeping it simple) I am thinking I need a table for every > account which mig

Re: [SQL] How to pass array of values to a stored procedure

2006-07-18 Thread Tony Wasson
On 7/18/06, Tony Wasson <[EMAIL PROTECTED]> wrote: On 7/18/06, Curtis Scheer <[EMAIL PROTECTED]> wrote: > Does anyone have any examples of how I would make a stored procedure in > plpgsql that would allow for passing a list or arrays of values to be used > in an sql IN cla

Re: [SQL] How to pass array of values to a stored procedure

2006-07-18 Thread Tony Wasson
On 7/18/06, Curtis Scheer <[EMAIL PROTECTED]> wrote: Does anyone have any examples of how I would make a stored procedure in plpgsql that would allow for passing a list or arrays of values to be used in an sql IN clause? Like so: select * from table where field1 in (values). Here's a very sim

Re: [SQL] help..postgresql mulyiple return values

2006-05-18 Thread Tony Wasson
On 5/12/06, Michael Joseph Tan <[EMAIL PROTECTED]> wrote: hi, im new in postgresql, generally new in databases. im trying to make a function using PGAdminIII which returns several types, example, my query is: "select count(id) as requests, organization from connection_requests group by organiz

Re: [SQL] Function Dependency

2006-02-05 Thread Tony Wasson
I ended up writing a perl script to parse my SQL and make a graphviz dot file. I then used graphviz to make a function dependency chart. I can't promise it would catch every single case, but I can provide you with the code if you wish to give it a whirl. Tony Wasson -

Re: [SQL] psql client: technique for applying default values to :variables?

2006-01-11 Thread Tony Wasson
On 1/11/06, Jeff Boes <[EMAIL PROTECTED]> wrote: > Stumped: is there any way to set up default values for psql variables > within the .SQL file itself? Obviously, I can do something like: > > $ psql -f my_script -v MYVAR=${myvar:-mydefault} > > but I would prefer to have the value stored with the .

Re: [SQL] Multi-column returns from pgsql

2005-07-22 Thread Tony Wasson
On 7/22/05, Jim Buttafuoco <[EMAIL PROTECTED]> wrote: > Mark, > > Instead of RETURN NEXT rec.txt1; RETURN NEXT rec.txt2; just use RETURN NEXT > rec; > > then your select statement would be > select * from my_func() as (txt1 text,txt2 text); > > Jim Besides a simple RETURN NEXT, you'll need to

Re: [SQL] echo/printf function in plpgsql

2005-07-19 Thread Tony Wasson
On 7/19/05, Andreas Joseph Krogh <[EMAIL PROTECTED]> wrote: > On Tuesday 19 July 2005 17:18, Richard Huxton wrote: > > Andreas Joseph Krogh wrote: > > > Hi all! > > > > > > Is there a way of echo'ing a string(like "raise notice 'this is id%', > > > id") from plpgsql? I want to echo/print it to STDO

Re: [SQL] funstions for parsing words

2005-07-19 Thread Tony Wasson
sible? > > Thanks alot. > > Your Friend, > > John Kopanas You can do this by using array_to_string and using a space as your delimiter. If you need to trim the quotes use the trim function also. You can also see the split_on_commas example below -- you'd want to split on

Re: [SQL] left joins

2005-07-06 Thread Tony Wasson
h left join p on (h.r=p.r and h.pos=r.pos and p.r_order=1) where h.tn > 20 and h.tn < 30 Filtering within the join condition is very useful when doing a left outer join. Here's another example "from the book" doing this type of filter within the join: http://www.postgresql

Re: [SQL] 3 tables, slow count(*), order by Seq Scan in Query Plan

2005-05-27 Thread Tony Wasson
eriodic summarization you run. This sounds like a "top N" report so a periodic update out to work. http://jonathangardner.net/PostgreSQL/materialized_views/matviews.html Tony Wasson ---(end of broadcast)--- TIP 8: explain analyze is your friend

Re: [SQL] Help: Function for splitting VARCHAR column and migrating its data to 2 new tables

2005-05-24 Thread Tony Wasson
le row by using something like SELECT build_keyword_table('123'); I also used this as my test data... It worked for me! CREATE TABLE user_data ( id SERIAL, user_id INTEGER, keywords VARCHAR(256) NOT NULL, add_date TIMESTAMP, PRIMARY KEY(id) ); INSERT

Re: [SQL] default value for select?

2005-05-09 Thread Tony Wasson
On 5/9/05, Mark Fenbers <[EMAIL PROTECTED]> wrote: > I want to update a column in myTable. The value this column is set to > depends on a nested select statement which sometimes returns 0 rows instead > of 1. This is a problem since the column I'm trying to update is set to > refuse nulls. Here

Re: [SQL] Looking for a way to sum integer arrays....

2005-04-29 Thread Tony Wasson
um_integer_array(somearr) FROM arraytest ; sum_integer_array ------- {1,3,5} (1 row) Tony Wasson ---(end of broadcast)--- TIP 8: explain analyze is your friend

[SQL] Looking for a way to sum integer arrays....

2005-04-22 Thread Tony Wasson
x_sum example in the docs. - CREATE OR REPLACE FUNCTION sum_intarray(INTEGER[],INTEGER[]) RETURNS INTEGER[] LANGUAGE 'plpgsql' AS ' /* || Author: Tony Wasson || || Overview: Experiment with arrays and aggregates || 3,2,1 ||+ 0,2,2 || --- || 3,4,3 || || Revisions