Re: [SQL] RE: pl/pgsql and returning rows

2001-03-28 Thread Richard Huxton
From: "Bruce Momjian" <[EMAIL PROTECTED]> > MY book in chapter 18 has a Pl/PgSQL function called change_statename > that does insert/update automatically. > > http://www.postgresql.org/docs/awbook.html The functions called get_details though, so I assumed it's supposed to be shorthand for a joi

[SQL] DELETE FROM fails with error

2001-03-28 Thread chris Günther
Hi folks, I have the problem that I can't delete datasets out of my tables. It's like that: I have a table: tblshop ID_Shop oid with sequence --- Sh_Name ID_Country ... there is an index on ID_Country I have a second table: tblcountry ID_Cou

[SQL] Killing Postmaster

2001-03-28 Thread Graham Vickrage
Hi All, What is the correct way of killing postgres 7.0 on redhat linux. Is there a reason why vacuum hangs on a DB with about 1.5 million rows? Cheers Graham winmail.dat ---(end of broadcast)--- TIP 6: Have you searched our list archives?

Re: [SQL] Killing Postmaster

2001-03-28 Thread Poul L. Christiansen
On Wed, 28 Mar 2001, Graham Vickrage wrote: > Hi All, > > What is the correct way of killing postgres 7.0 on redhat linux. "man pg_ctl". > > Is there a reason why vacuum hangs on a DB with about 1.5 million rows? Vacuum can take a long time with 1.5M records. How long have you waited? Is the

Re: [SQL] Killing Postmaster

2001-03-28 Thread Poul L. Christiansen
A week? That sounds much too long to me (assuming that you have PostgresSQL funning on fairly good hardware). There could be something wrong with at specific table. Try to vacuum a table one at the time using "vacuum verbose MyTable", and report any error you may find. I don't understand the ou

[SQL] counting distinct rows on more than one column

2001-03-28 Thread Dirk Lutzebaeck
Hi, on 7.0.3 want to COUNT SELECT DISTINCT a,b FROM t; I can't find a solution because any combination with count with more than one column gives syntax errors. One solution would be to set a view: CREATE VIEW v AS SELECT DISTINCT a,b FROM t; and then SELECT count(a) FROM v but views do

RE: [SQL] counting distinct rows on more than one column

2001-03-28 Thread Michael Ansley
Title: RE: [SQL] counting distinct rows on more than one column SELECT count(*) FROM (SELECT DISTINCT a, b FROM t) AS t2; should give you what you want. MikeA >> -Original Message- >> From: Dirk Lutzebaeck [mailto:[EMAIL PROTECTED]] >> Sent: 28 March 2001 16:11 >> To: [EMAIL PR

Re: [SQL] DELETE FROM fails with error

2001-03-28 Thread Josh Berkus
Chris, > I have a reference between these two tables pointing from > tblshop.ID_Country to > tblcountry.ID_Country > > When I try to delete a row from tblshop I get the error that postgres > can't find > the attribute id_shop. My SQL-command looks like follows: > > DELETE FROM tblshop WH

Re: [SQL] counting distinct rows on more than one column

2001-03-28 Thread Michael Fork
In 7.0.3, I believe the following would work: SELECT count(distinct(a || b)) FROM t; if subselects in from were supported in 7.0.3 as they are in 7.1, you could do: SELECT count(*) FROM (SELECT DISTINCT a,b FROM t) FROM x Michael Fork - CCNA - MCP - A+ Network Support - Toledo Internet Access

Re: [SQL] DELETE FROM fails with error

2001-03-28 Thread Tom Lane
chris Günther <[EMAIL PROTECTED]> writes: > When I try to delete a row from tblshop I get the error that postgres > can't find the attribute id_shop. My SQL-command looks like follows: > DELETE FROM tblshop WHERE tblshop."ID_Shop" = 12 That looks like the correct way of quoting a mixed-cas

Re: [SQL] counting distinct rows on more than one column

2001-03-28 Thread Tom Lane
Dirk Lutzebaeck <[EMAIL PROTECTED]> writes: > on 7.0.3 want to COUNT > SELECT DISTINCT a,b FROM t; In 7.1 you could do select count(*) from (select distinct a,b from t) as t1; In 7.0 and before I think you have no choice but to use a temp table. regards, tom l

[SQL] Function with now() | time 'now' | etc...

2001-03-28 Thread edipoelder
Hi all, I wrote the folling function: DROP FUNCTION PROC_TESTE(INTEGER); CREATE FUNCTION PROC_TESTE(INTEGER) RETURNS INTEGER AS ' DECLARE SEQ RECORD; BEGIN SELECT NEXTVAL(''TEMPOS_ID_SEQ'') AS ID INTO SEQ; INSERT INTO TEMPOS (ID, INICIO) VALUES (SEQ.ID, NOW())

Re: [SQL] Oracle -> Postgresql migration

2001-03-28 Thread Roberto Mello
On Wed, Mar 28, 2001 at 01:24:11PM -0500, Douglas Brunton wrote: > Hello, > I am currently in the process of attempting an Oracle 8i to Postgresql 7.0.3 >migration. The table conversions were pretty straight forward, and I have all of the >tables ported over (with some minor datatype conversi

Re: [SQL] Function with now() | time 'now' | etc...

2001-03-28 Thread Tom Lane
[EMAIL PROTECTED] writes: > It doesn't getting different times on each execution. I also tried put > "timestamp 'now'" insted "now()". What am I doing wrong? now() is defined to return the time of the start of the current transaction. It won't change value inside a transaction. See http:/

Re: [SQL] counting distinct rows on more than one column

2001-03-28 Thread Dirk Lutzebaeck
Michael Fork writes: > In 7.0.3, I believe the following would work: > > SELECT count(distinct(a || b)) FROM t; Great, this works! I don't quite get it why... Dirk ---(end of broadcast)--- TIP 3: if posting/reading through Usenet, please send

Re: [SQL] counting distinct rows on more than one column

2001-03-28 Thread Tom Lane
Dirk Lutzebaeck <[EMAIL PROTECTED]> writes: > Michael Fork writes: >>> In 7.0.3, I believe the following would work: >>> >>> SELECT count(distinct(a || b)) FROM t; > Great, this works! I don't quite get it why... Michael really should not have proposed that solution without mentioning its limit

Re: [SQL] DELETE FROM fails with error

2001-03-28 Thread Stephan Szabo
I was going to guess that it was something related to the foreign key, but I can't imagine why that would be affected by a delete on the referencing table (there shouldn't be a trigger there anyway). Can you send full schema with constraints for the tables? On Wed, 28 Mar 2001, chris Günther wr

[SQL] RE: counting distinct rows on more than one column

2001-03-28 Thread Jeff Eckermann
I don't think this will necessarily work: field1 | field2 aa | ab a | aab These are two distinct rows, so should be counted as two. The proposed method would count them as one. You can get around this problem by doing: count (distinct (a || x || b)) where x is some character not foun

Re: [SQL] RE: counting distinct rows on more than one column

2001-03-28 Thread Jim Ballard
If the fields are fixed length character type, then the simpler concatenation should work. Actually, the requirement is only that all but the final field be fixed length. And if they aren't fixed length, you can cast them to be such, as long as you know the maximum length of the string values, a

[SQL] SELECT ... FOR UPDATE

2001-03-28 Thread Marcos Minshew
I am interested in using the SELECT ... FOR UPDATE feature but it doesn't work quite the way I had hoped. If there is a better/different way of doing this please enlighten me. If I issue: BEGIN; SELECT * FROM atable WHERE atable.key = 10 FOR UPDDATE; in one session and then issue the same comm

[SQL] Self-Referencing

2001-03-28 Thread David Olbersen
Hello, I have a feeling this isn't going to make much sense, but I'm gonig to try anyway. What I'd like to do is be able to refer to an outer-SELECT from an inner-SELECT. I hope this makes sense. I need to be able to refer to the row that's being processed in a SELECT. I'm going to

[SQL] Can a SELECT block?

2001-03-28 Thread Gerald Gutierrez
Hi all. I'm trying to track down a deadlock problem caused by some automatically generated SQL code. It seems I'm deadlocking on a table that is actually quite rarely modified. I'm unsure, but it appears that maybe something is blocking on a SELECT call. Under what situations can a SELECT block

Re: [SQL] Can a SELECT block?

2001-03-28 Thread Tom Lane
"Gerald Gutierrez" <[EMAIL PROTECTED]> writes: > Under what situations can a SELECT block? If the table is locked with an exclusive lock. See http://www.postgresql.org/devel-corner/docs/postgres/locking-tables.html > I'd appreciate any time. To give some details, it appears that my > applicatio

[SQL] 3 options

2001-03-28 Thread Patrick Coulombe
Hi, Using : PostgreSQL 6.5.3 on i686-pc-linux-gnu Platform : Linux (Red Hat 6.0) 3 errors : 1) pg_dump medias > medias.pgdump280301 pqWait() -- connection not open PQendcopy: resetting connection SQL query to dump the contents of Table 'dossier' did not execute correctly. After we read all th

[SQL] Oracle -> Postgresql migration

2001-03-28 Thread Douglas Brunton
Hello,   I am currently in the process of attempting an Oracle 8i to Postgresql 7.0.3 migration.  The table conversions were pretty straight forward, and I have all of the tables ported over (with some minor datatype conversions).  The stored procedures are a different case altogether.  I am