Re: [SQL] Functions, transactions and RETURN

2005-09-22 Thread Stewart Ben (RBAU/EQS4) *
Hate to reply to my own posts, but I thought the solution I've come across may help others with problems implementing savepoints and transactions in functions. This function implements rollbacks whilst still returning a valid row instead of an exception. A temporary variable is used to get around

[SQL] Issue with UPDATE statement on v8

2005-09-22 Thread Kenneth Hutchinson
Hello,   We have recently migrated to Postgres 8 (not sure of exactly which build).  We have noticed that a few functions that were working previously are no longer behaving as expected.  One function in particular is giving me a strange result.   The function giving us the problem is much

[SQL] Difficulties with a master-detail query

2005-09-22 Thread Milen A. Radev
Hi, list! You have most probably met the same problem: I have a master table, describing the objecs I'm interested in - let's say employees. I have a details table, defining all possible values of one of the properties of the objects - let's say languages spoken. And of course I have a table desr

[SQL] Functions, transactions and RETURN

2005-09-22 Thread Stewart Ben (RBAU/EQS4) *
After reading up on Postgres documentation, it seems that transactions and savepoints are not available to functions, and savepoints are implemented via BEGIN.. EXCEPTION.. END blocks. I have a function returning an int4 with the following proposed structure: -

Re: [SQL] Primary and Foreign Key?

2005-09-22 Thread Russell Simpkins
This is valid ddl to accomplish what you wish. create table peoplegroups { peopleid int not null, groupid int not null, primary key (peopleid, groupid), foreign key (peopleid) references people, foreign key (groupid) references group } Check the docs for other options etc. From: "Announce" <[

[SQL] Primary and Foreign Key?

2005-09-22 Thread Announce
I have the following related tables: PEOPLE -- peopleid pkey, name, etc GROUPS - groupid pkey, description, etc PEOPLEGROUPS --- peopleid pkey/fkey, groupid pkey/fkey What is the CORRECT way (in Postgres) to define the PEOPLEGROUPS table so that it has

Re: [SQL] Using descriptor areas to insert

2005-09-22 Thread Josh Berkus
Andrew, > I'm in the final stages of porting a large body of ESQL software from > Informix to PostgreSQL (V8). The last few Informix-based functions > involve Informix descriptor areas to insert rows into a table. I've > sorted out the logic for using PostgreSQL descriptor areas for select > state

Re: [SQL] Help with a view

2005-09-22 Thread Dmitri Bichko
I don't understand how this is different: SELECT person FROM principals WHERE event IN (SELECT event FROM principals WHERE person = $p AND tag_type = " .MARR. ") AND person != $p ORDER BY sort_date Or without subselects: SELECT p1.person FROM principals p1 JOIN principals p2 USING(event) WHERE p

Re: [SQL] Issue with UPDATE statement on v8

2005-09-22 Thread Rajesh Kumar Mallah
On 9/23/05, Kenneth Hutchinson <[EMAIL PROTECTED]> wrote: > Hello, > > I'm sorry if this has been sent to the community multiple times. I am > not able to determine whether my posts have gotten through. If you have > rec'd this multiple times, please let me know. > > We have recently migrated to

Re: [SQL] Issue with UPDATE statement on v8

2005-09-22 Thread Tom Lane
"Kenneth Hutchinson" <[EMAIL PROTECTED]> writes: > UPDATE t_summary > SETavailability = 7 > WHERE oid = 28245084 > When this query is executed (within a function or without) the database > will simply hang. Is it really hung, or just taking an awfully long time? If the backend is consum

Re: [SQL] Help with a view

2005-09-22 Thread Rajesh Kumar Mallah
> Basically, what I've got is the first person and the tag_type. I can do > it with a function from PHP: > > function get_spouses($p) { > $handle = pg_query("select person from principals >where event in (select event from principals >where person

[SQL] Issue with UPDATE statement on v8

2005-09-22 Thread Kenneth Hutchinson
Hello, I'm sorry if this has been sent to the community multiple times. I am not able to determine whether my posts have gotten through. If you have rec'd this multiple times, please let me know. We have recently migrated to Postgres 8 (not sure of exactly which build). We have noticed that a

Re: [SQL] Updating cidr column with network operator

2005-09-22 Thread Daryl Richter
Axel Rau wrote: Thank you for responding, Daryl, Am 22.09.2005 um 16:45 schrieb Daryl Richter: Axel Rau wrote: Hi SQLers, I have a fk from address to network and try to update the foreign key column to point at the network, "it belongs to": CREATE TABLE network ( id cidr PRIMARY

Re: [SQL] Help with a view

2005-09-22 Thread Leif B. Kristensen
On Thursday 22 September 2005 20:03, Dmitri Bichko wrote: > SELECT * FROM principals WHERE event = 15821 AND person != 2? Sure, that's a concise answer to what I actually wrote, but it wasn't exactly what I intended :) Basically, what I've got is the first person and the tag_type. I can do it

Re: [SQL] Help with a view

2005-09-22 Thread Dmitri Bichko
SELECT * FROM principals WHERE event = 15821 AND person != 2? Dmitri > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Leif B. > Kristensen > Sent: Thursday, September 22, 2005 1:30 PM > To: pgsql-sql@postgresql.org > Subject: [SQL] Help with a view

Re: [SQL] Updating cidr column with network operator

2005-09-22 Thread Axel Rau
Thank you for responding, Daryl, Am 22.09.2005 um 16:45 schrieb Daryl Richter: Axel Rau wrote: Hi SQLers, I have a fk from address to network and try to update the foreign key column to point at the network, "it belongs to": CREATE TABLE network ( id cidr PRIMARY KEY , -- 'PK,

[SQL] Help with a view

2005-09-22 Thread Leif B. Kristensen
I've created a view 'principals' that gives me this output: pgslekt=> select * from principals where event=15821; person | event | place | sort_date | tag_type +---+---++-- 2 | 15821 | 1152 | 1999-09-17 |4 3 | 15821 | 1152 | 1999-09-17 |

[SQL] Using descriptor areas to insert

2005-09-22 Thread andy rost
I'm in the final stages of porting a large body of ESQL software from Informix to PostgreSQL (V8). The last few Informix-based functions involve Informix descriptor areas to insert rows into a table. I've sorted out the logic for using PostgreSQL descriptor areas for select statements. How do y

Re: [SQL] Updating cidr column with network operator

2005-09-22 Thread Daryl Richter
Axel Rau wrote: Hi SQLers, I have a fk from address to network and try to update the foreign key column to point at the network, "it belongs to": CREATE TABLE network ( id cidr PRIMARY KEY , -- 'PK, ,IPv4/6 Network address' ) CREATE TABLE address ( id inet PRIMAR

Re: [SQL] postgres on the comman line

2005-09-22 Thread Achilleus Mantzios
O "Michael Hφller" έγραψε στις Sep 22, 2005 : > > > Hello, > > I like to automate a daily check and like to run select statement via > cron but this seems to be more tricky than I thought > > I tried the following: > su postgres -c "select count(*) from TABLE where xx;" Firstoff, 'sel

Re: [SQL] postgres on the comman line

2005-09-22 Thread A. Kretschmer
am 22.09.2005, um 15:55:53 +0200 mailte "Michael Höller" folgendes: > > > Hello, > > I like to automate a daily check and like to run select statement via > cron but this seems to be more tricky than I thought > > I tried the following: > su postgres -c "select count(*) from TABLE where xx

Re: [SQL] postgres on the comman line

2005-09-22 Thread Thomas Pundt
Hi Michael, On Thursday 22 September 2005 15:55, Michael Höller wrote: | I like to automate a daily check and like to run select statement via | cron but this seems to be more tricky than I thought | | I tried the following: | su postgres -c "select count(*) from TABLE where xx;" you mean

[SQL] postgres on the comman line

2005-09-22 Thread Michael Höller
Hello, I like to automate a daily check and like to run select statement via cron but this seems to be more tricky than I thought I tried the following: su postgres -c "select count(*) from TABLE where xx;" I have the probelm that I am allways asked for the password - I did not find a

Re: [SQL] Copy Views From Database?

2005-09-22 Thread Hannes Dorbath
On 22.09.2005 11:47, [EMAIL PROTECTED] wrote: How would you use it to only dump / restore the views? I don't want any database tables. Please RTFM. But because I'm such a nice guy: Create a binary dump of the schema: pg_dump -v -s -i -F c -Z 9 -U -f /tmp/dump.bin Use the -l option of pg_re

[SQL] Updating cidr column with network operator

2005-09-22 Thread Axel Rau
Hi SQLers, I have a fk from address to network and try to update the foreign key column to point at the network, "it belongs to": CREATE TABLE network ( id cidr PRIMARY KEY , -- 'PK, ,IPv4/6 Network address' ) CREATE TABLE address ( id inet PRIMARY KEY , -

Re: [SQL] Copy Views From Database?

2005-09-22 Thread Hannes Dorbath
On 22.09.2005 10:37, [EMAIL PROTECTED] wrote: Is there a maybe a tool that I can use to copy views as-is from one database into another? pg_dump and pg_restore :) ---(end of broadcast)--- TIP 4: Have you searched our list archives?

Re: [SQL] Copy Views From Database?

2005-09-22 Thread Hannes Dorbath
use pg_dump and pg_restore :) On 22.09.2005 10:37, [EMAIL PROTECTED] wrote: Hi Guys, I'm using PostGreSQL with a Java project since I'm a proffesional Java developer. I've a database that have about 120 views in PostGreSQL 7.0 that I need to copy into PostGreSQL 8.0. I can copy them one-by-one

[SQL] cancel <[EMAIL PROTECTED]>

2005-09-22 Thread light
This message was cancelled from within Mozilla. ---(end of broadcast)--- TIP 3: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faq

[SQL] Copy Views From Database?

2005-09-22 Thread [EMAIL PROTECTED]
Hi Guys, I'm using PostGreSQL with a Java project since I'm a proffesional Java developer. I've a database that have about 120 views in PostGreSQL 7.0 that I need to copy into PostGreSQL 8.0. I can copy them one-by-one in pgAdmin but I don't have the time! Is there a maybe a tool that I can use t