Re: [SQL] COUNT func

2001-10-18 Thread Bhuvan A
hi, try this too.. select count(*),age,status from person where age=40 and status='MARRIED' group by age,status; Regards, Bhuvaneswar. On Oct 18, Oleg Lebedev wrote: > Hi, > I am trying to count the number or rows in a table with similar field > values. I want to do it in one table sca

[SQL] Table Constraints with NULL values

2001-10-18 Thread David Allardyce
It appears that Postgres will allow any INSERT, despite a multiple-column constraint, if any of the values INSERTed are NULL. If I read the included excerpt correctly (there are like three negatives in the second sentence, sheesh :) ), multiple NULL values for a column are acceptable or, in other

Re: [SQL] When will vacuum go away?

2001-10-18 Thread Joseph Shraibman
BTW will there be a 7.1.4 release before 7.2 comes out so we can dump our databases to upgrade to 7.2 w/o there being 60 in the seconds field? Tom Lane wrote: > "Michael Richards" <[EMAIL PROTECTED]> writes: > >>I've been watching for this for some time. First it was 7.0, then >>7.1. Does any

Re: [SQL] COUNT func

2001-10-18 Thread Stephan Szabo
On Thu, 18 Oct 2001, Oleg Lebedev wrote: > Hi, > I am trying to count the number or rows in a table with similar field > values. I want to do it in one table scan. > In other words, say I want to count the number of rows in Person table, > having age equal to 40, and the number of rows with stat

[SQL] oid's in views.

2001-10-18 Thread Aasmund Midttun Godal
CREATE VIEW testview AS SELECT test.oid, tull FROM test; ERROR: Attribute 'oid' has a name conflict Name matches an existing system attribute I think this should be allowed, because if you do: CREATE VIEW testview AS SELECT tull FROM test; SELECT oid, tull FROM testview; The oid column

Re: [SQL] index question

2001-10-18 Thread Tom Lane
Joseph Shraibman <[EMAIL PROTECTED]> writes: > Lets say I have a table with columns a and b. I want to do a query like > SELECT count(distinct b) WHERE a = 2; > Should I have an index on a or an index on (a,b)? At present, only an index on a will help any. Our implementation of count(distinct

[SQL] Access to functions

2001-10-18 Thread Aasmund Midttun Godal
There is currently no functionality to grant or deny access to functions. I believe anyone can run any function and the function is run as the user who runs it. This is also the case with views, which is odd, as the rest of the select statement is granted access to a table which the function in

Re: [SQL] When will vacuum go away?

2001-10-18 Thread Tom Lane
Joseph Shraibman <[EMAIL PROTECTED]> writes: > BTW will there be a 7.1.4 release before 7.2 comes out so we can dump > our databases to upgrade to 7.2 w/o there being 60 in the seconds > field? I doubt it. We're having enough trouble trying to get everyone lined up to produce a 7.2 beta :-(. Pr

[SQL] index question

2001-10-18 Thread Joseph Shraibman
Lets say I have a table with columns a and b. I want to do a query like SELECT count(distinct b) WHERE a = 2; Should I have an index on a or an index on (a,b)? -- Joseph Shraibman [EMAIL PROTECTED] Increase signal to noise ratio. http://www.targabot.com ---(end of br

Re: [SQL] [ADMIN] update in rule

2001-10-18 Thread Oleg Lebedev
You can use the following to install plpgsql: CREATE FUNCTION plpgsql_call_handler () RETURNS OPAQUE AS '/usr/local/pgsql/lib/plpgsql.so' LANGUAGE 'C'; CREATE TRUSTED PROCEDURAL LANGUAGE 'plpgsql' HANDLER plpgsql_call_handler LANCOMPILER 'PL/pgSQL'; I assume that you have defaul

Re: [SQL] Doing a regexp-based search/replace?

2001-10-18 Thread Brett Schwarz
You could write a Tcl (i.e. pltcl) function, and use that to do what you want: CREATE FUNCTION remove(varchar) RETURNS varchar AS ' set input $1 regsub -- {-.*$} $input {} output return $output ' language 'pltcl'; [NOTE: untested] you may have to monkey with the reg

Re: [SQL] COUNT func

2001-10-18 Thread Oleg Lebedev
It worked! I checked the query plan it generates, and it's really a one-pass scan. thanks, Oleg Stephan Szabo wrote: > On Thu, 18 Oct 2001, Oleg Lebedev wrote: > > > Hi, > > I am trying to count the number or rows in a table with similar field > > values. I want to do it in one table scan. > >

Re: [SQL] Doing a regexp-based search/replace?

2001-10-18 Thread Josh Berkus
Steve, > I've got a table containing property_id's with values of the form > ###-. I would like to discard the slash onwards (and I can't use > a > substr() because I am not guaranteed if a) the - portion exists, > b) > what position it exists from. > > If this were a text file, I would

[SQL] COUNT func

2001-10-18 Thread Oleg Lebedev
Hi, I am trying to count the number or rows in a table with similar field values. I want to do it in one table scan. In other words, say I want to count the number of rows in Person table, having age equal to 40, and the number of rows with status as 'married'. I want Person table to be scanned on

Re: [SQL] Doing a regexp-based search/replace?

2001-10-18 Thread Tom Lane
Steve Frampton <[EMAIL PROTECTED]> writes: > If this were a text file, I would use a sed expression such as: > cat textfile | sed 's/-.*$//' > I've been looking for a way to do this with PostgreSQL but so far haven't > found a function that seems to be suitable. Write a function in pltcl or plper

Re: [SQL] Doing a regexp-based search/replace?

2001-10-18 Thread Stephan Szabo
Well, the easiest general way is probably a plperl function, but I think the following may work for your specific case: update mytable set property_id=substr(property_id, 1, position('-' in property_id)-1) where position('-' in property_id)!=0; On Thu, 18 Oct 2001, Steve Frampton wrote: >

[SQL] Granting database level permissions...

2001-10-18 Thread Thomas Swan
Is it possible to grant database level access to a user in PostgreSQL? I have created a user and database, and I want the user to have full control over that database. I have been through the online docs and news groups but have not found a statement or answer to the question. Thomas

[SQL] Doing a regexp-based search/replace?

2001-10-18 Thread Steve Frampton
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hello: I've got a table containing property_id's with values of the form ###-. I would like to discard the slash onwards (and I can't use a substr() because I am not guaranteed if a) the - portion exists, b) what position it exists from. If

Re: [SQL] Replication

2001-10-18 Thread Josh Berkus
Ray, > Does Postgres in anyway support replication? Will I be able to have > load-balancing between two postgres databases? Not at this time. GreatBridge was working on replication when they shut down. It's very likely that Red Hat will add replication once they get up to speed on Postgres, b

Re: [SQL] Replication

2001-10-18 Thread clayton cottingham
> "Hunter, Ray" wrote: > > Does Postgres in anyway support replication? Will I be able to have > load-balancing between two postgres databases? > > RAY HUNTER > Automated Test Group > Software Support Engineer > > ENTERASYS NETWORKS > > Internal: 53888 > Phone: 801 887-9888 > Fax:

[SQL] Replication

2001-10-18 Thread Hunter, Ray
Title: Replication Does Postgres in anyway support replication?  Will I be able to have load-balancing between two postgres databases? RAY HUNTER Automated Test Group Software Support Engineer   ENTERASYS NETWORKS   Internal: 53888 Phone:   801 887-9888 Fax:  801 972-5789 Cel

Re: [SQL] Deleting obsolete values

2001-10-18 Thread Henshall, Stuart - WCP
DELETE FROM partitur WHERE EXISTS (SELECT * FROM partitur AS ss_partitur WHERE ss_partitur.userid=partitur.userid AND ss_partitur.ts>partitur.ts); Seems like it should seems like it should delete all old values (however I have not tested it) - Stuart > -Original Message- > From: Haller Ch

Re: [SQL] index problem

2001-10-18 Thread CoL
Hi, Stephan Szabo wrote: > On Tue, 16 Oct 2001, CoL wrote: > > >>--- >>The 2 table query, where prog_data has ~8800 rowsn and index on prog_id: >>bash-2.04$ time echo "explain select distinct >>prog_id,prog_ftype,prog_fcasthour,prog_date from prog_dgy_xy,prog_data >>w

Re: [SQL] Text/Image, JSP tomcat. How can I operate the text and image

2001-10-18 Thread Henshall, Stuart - WCP
Have a look at lo_import and lo_export. Can handle chunks at a time Also bytea type. You have to handle complete items with this. Although it'd need some formating. I believe zeros go to \000, ' to \' and \ to \\ as a bare minimum, but am not at all sure on that. - Stuart > -Original Message-