Re: [SQL] Unique key field or serverl fks ?

2004-01-12 Thread Richard Huxton
On Monday 12 January 2004 05:51, katarn wrote:
 Hi,

 I would like to know opinions about which approach is better:

 Having a table with a field that works as a unique key, or having
 several fks that work as a combined key ( all the fks fields )?

Depends on the particular situation, you'll need to give details of the tables 
and their place in your system.

There are two reasons I've seen given for using an artificial (substitute) 
primary key:
1. It's lighter than several other fields (especially where they are text)
2. The natural primary key has meaning to the users, and the users will tend 
to get it wrong.

The second is probably the more persuasive - the first can definitely have 
costs as well as benefits.

-- 
  Richard Huxton
  Archonet Ltd

---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]


[SQL] Triggers

2004-01-12 Thread beyaRecords - The home Urban music
Hi,
does postgresql support the ability to email as in SQL Server? I want 
to create a trigger which on input of a record will send out an email. 
Is this possible?

Uzo

---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
 subscribe-nomail command to [EMAIL PROTECTED] so that your
 message can get through to the mailing list cleanly


Re: [SQL] Triggers

2004-01-12 Thread Peter Eisentraut
beyaRecords - The home Urban music wrote:
 does postgresql support the ability to email as in SQL Server? I want
 to create a trigger which on input of a record will send out an
 email. Is this possible?

Write a trigger function in, say, PL/PerlU or PL/sh and have it send the 
email with the usual Perl or shell commands.


---(end of broadcast)---
TIP 8: explain analyze is your friend


Re: [SQL] Triggers

2004-01-12 Thread Sai Hertz And Control Systems
Dear Uzo  ,

Hi,
does postgresql support the ability to email as in SQL Server? I want 
to create a trigger which on input of a record will send out an email. 
Is this possible?
http://pgmail.sourceforge.net/ is what you need.

Regards,

Vishal Kashyap

---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
 subscribe-nomail command to [EMAIL PROTECTED] so that your
 message can get through to the mailing list cleanly


Re: [SQL] Triggers

2004-01-12 Thread Richard Huxton
On Monday 12 January 2004 16:14, beyaRecords - The home Urban music wrote:
 Hi,
 does postgresql support the ability to email as in SQL Server? I want
 to create a trigger which on input of a record will send out an email.
 Is this possible?

Have a look in the mailing list archives - this has been covered recently. I 
seem to recall there is an add-on that does just this.

-- 
  Richard Huxton
  Archonet Ltd

---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster


[SQL] Transpose rows to columns

2004-01-12 Thread David Witham
Hi,

I have a query that returns data like this:

cust_id cust_name   month   costrevenue margin
991234  ABC 2003-07-01  10  15  5
991234  ABC 2003-08-01  11  17  6
991234  ABC 2003-09-01  12  19  7
991235  XYZ 2003-07-01  13  21  8
991235  XYZ 2003-08-01  12  19  7
991235  XYZ 2003-09-01  11  17  6

I want to turn it around so it displays like this:

991234,ABC,2003-07-01,10,15,5,2003-08-01,11,17,6,2003-09-01,12,19,7
991235,XYZ,2003-07-01,13,21,8,2003-08-01,12,19,7,2003-09-01,11,17,6

(I've used commas to shorten the layout for the example)

Does anyone have some ideas on how to do this?

Thanks,

David Witham
Telephony Platforms Architect
Unidial
Ph: 03 8628 3383
Fax: 03 8628 3399


---(end of broadcast)---
TIP 9: the planner will ignore your desire to choose an index scan if your
  joining column's datatypes do not match


Re: [SQL] Transpose rows to columns

2004-01-12 Thread Michael Glaesemann
Hi David
On Jan 13, 2004, at 10:12 AM, David Witham wrote:
Hi,

I have a query that returns data like this:

cust_id cust_name   month   costrevenue margin
991234  ABC 2003-07-01  10  15  5
991234  ABC 2003-08-01  11  17  6
991234  ABC 2003-09-01  12  19  7
991235  XYZ 2003-07-01  13  21  8
991235  XYZ 2003-08-01  12  19  7
991235  XYZ 2003-09-01  11  17  6
I want to turn it around so it displays like this:

991234,ABC,2003-07-01,10,15,5,2003-08-01,11,17,6,2003-09-01,12,19,7
991235,XYZ,2003-07-01,13,21,8,2003-08-01,12,19,7,2003-09-01,11,17,6
(I've used commas to shorten the layout for the example)

Does anyone have some ideas on how to do this?
I'd suggest looking at tablefunc in /contrib. It includes crosstab 
functionality that you might find useful. I don't think it'll do 
exactly what you describe here, but something quite similar.

Michael Glaesemann
grzm myrealbox com
---(end of broadcast)---
TIP 6: Have you searched our list archives?
  http://archives.postgresql.org