[SQL] Urgent Help : Use of return from function/procedure.

2003-06-22 Thread Anagha Joshi
Title: Urgent Help : Use of return from function/procedure. Hi, I'm new to postgres and using version 7.2.4 I've created a trigger and function which does the following:     trigger 'T' fires after insert on a spcific table takes place and it executes function 'F' Function 'F' retur

Re: [SQL] Delete duplicates

2003-06-22 Thread Rudi Starcevic
Hi, Would this be OK or a little crude (untested) : INSERT INTO new_table ( id, something ) SELECT DISTINCT ON (id) id, something FROM old_table ORDER BY id Or something similar but create a new table ? Cheers Rudi. Denis Arh wrote: How to delete "real" duplicates? id | somthing

Re: [SQL] Delete duplicates

2003-06-22 Thread Tom Lane
"Denis Arh" <[EMAIL PROTECTED]> writes: > How to delete "real" duplicates? Use the OID or CTID system columns. regards, tom lane ---(end of broadcast)--- TIP 9: the planner will ignore your desire to choose an index scan if

Re: [SQL] Delete duplicates

2003-06-22 Thread Sean Chittenden
> How to delete "real" duplicates? > > id | somthing > --- > 1 | aaa > 1 | aaa > 2 | bbb > 2 | bbb > > (an accident with backup recovery...) I'm not 100% on some of the syntax off the top of my head, but: BEGIN; ALTER TABLE orig_table RENAME TO backup_table; CREATE TABLE ori

Re: [SQL] Delete duplicates

2003-06-22 Thread Denis Arh
How to delete "real" duplicates? id | somthing --- 1 | aaa 1 | aaa 2 | bbb 2 | bbb (an accident with backup recovery...) Regards, Denis Arh - Original Message - From: "Franco Bruno Borghesi" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent:

[SQL] virtual table

2003-06-22 Thread Tomasz Myrta
Hi I have another virtual problem, currently without any examples ;-) Let's say we have some pl/pgsql function which puts result into table1. This flat table must be normalized and put into table2. Sometimes 1 row from table1 = 1 row from table2, but sometimes 1 row from table1= 3 rows from table2

Re: [SQL] Delete duplicates

2003-06-22 Thread Franco Bruno Borghesi
try this DELETE FROM aap WHERE id NOT IN ( SELECT max(id) FROM aap GROUP BY keyword ); > > > Hi, > > I have a table with duplicates and trouble with my SQL. > I'd like to keep a single record and remove older duplicates. > For example below of the 6 recods I'd like to keep records > 4 a

Re: [SQL] Informing end-user of check constraint rules

2003-06-22 Thread Janning Vygen
Am Sonntag, 22. Juni 2003 14:45 schrieb [EMAIL PROTECTED]: > I have not used column check constraints before, but I'd like to start > using then and so would I'll like to know if there is a direct way to > provide feedback to the end user about data validation rules expressed in > column check cons

Re: [SQL] Delete duplicates

2003-06-22 Thread Germán Gutiérrez
Hi, you need find duplicates and then you remove them delete from aap where id not in ( select max(id) from aap b where aap.keyword = b.keyword ); Germán Sorry about my english -Mensaje original- De: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] En nombre de Rudi Starcevic Enviado el: Do

[SQL] Informing end-user of check constraint rules

2003-06-22 Thread btober
I have not used column check constraints before, but I'd like to start using then and so would I'll like to know if there is a direct way to provide feedback to the end user about data validation rules expressed in column check constraints? For instance, say that I wanted to use a RE to check e-ma

Re: [SQL] date question

2003-06-22 Thread Bruno Wolff III
On Fri, Jun 20, 2003 at 19:33:35 +0200, javier garcia - CEBAS <[EMAIL PROTECTED]> wrote: > Hi all; > > Peter, thank you very much for your help. Just a little thing. I've done as > you say: > > CREATE TABLE rain_series_dated AS SELECT (year * interval '1 year' + month * > interval '1 month' +

Re: [SQL] Delete duplicates

2003-06-22 Thread Paul Thomas
On 22/06/2003 10:15 Rudi Starcevic wrote: Hi, I have a table with duplicates and trouble with my SQL. I'd like to keep a single record and remove older duplicates. For example below of the 6 recods I'd like to keep records 4 and 6. TABLE: aap id | keyword +- 1 | LEAGUE

Re: [SQL] Delete duplicates

2003-06-22 Thread Ian Barwick
On Sunday 22 June 2003 11:15, Rudi Starcevic wrote: > Hi, > > I have a table with duplicates and trouble with my SQL. (...) > select a1.id > from aap a1 > where id < ( SELECT max(id) FROM aap AS a2 ) > AND EXISTS > ( > SELECT * > FROM aap AS a2 > WHERE a1.keyword = a2.keyword > ) How about (unte

[SQL] Delete duplicates

2003-06-22 Thread Rudi Starcevic
Hi, I have a table with duplicates and trouble with my SQL. I'd like to keep a single record and remove older duplicates. For example below of the 6 recods I'd like to keep records 4 and 6. TABLE: aap id | keyword +- 1 | LEAGUE PANTHERS 2 | LEAGUE PANTHERS 3 | LEA