Re: [SQL] Name Alike Challenge

2001-08-07 Thread Joe Conway
> The "Name Alike" PL/pgSQL function has been posted on Roberto Mello's > cookbook: > > http://www.brasileiro.net/postgres/cookbook/view-one-recipe.adp?recipe_id=96 7 > > This function requires Joe Conway's port of the Metaphone and > Levenshtein functions to PostgreSQL, available from /contrib on

Re: [SQL] loop on a rule

2001-08-07 Thread Martín Marqués
On Mar 07 Ago 2001 20:53, you wrote: > =?iso-8859-1?q?Mart=EDn=20Marqu=E9s?= <[EMAIL PROTECTED]> writes: > > As I said before, I am playing around with views and rules, and found out > > that I have something wrong in one of the rules. My delete rule says > > something like this: > > > > CREATE RU

Re: [SQL] loop on a rule

2001-08-07 Thread Tom Lane
=?iso-8859-1?q?Mart=EDn=20Marqu=E9s?= <[EMAIL PROTECTED]> writes: > As I said before, I am playing around with views and rules, and found out > that I have something wrong in one of the rules. My delete rule says > something like this: > CREATE RULE admin_delete AS ON > DELETE TO admin_view > D

[SQL] loop on a rule

2001-08-07 Thread Martín Marqués
As I said before, I am playing around with views and rules, and found out that I have something wrong in one of the rules. My delete rule says something like this: CREATE RULE admin_delete AS ON DELETE TO admin_view DO INSTEAD ( DELETE FROM carrera WHERE id_curso=old.id_curso; DELETE FROM

Re: [SQL] views and null bothering

2001-08-07 Thread Martín Marqués
On Lun 06 Ago 2001 21:02, Josh Berkus wrote: > Martin, > > > I have a bunch of tables which I give access through a view. The > > problem is > > that in the main table there are columns, that are referenced to > > another > > tables column, that have NULLs. > > In the SELECT inside the view's defi

Re: [SQL] Are circular REFERENCES possible ?

2001-08-07 Thread Jan Wieck
Josh Berkus wrote: > Jan, > > > All of this is wrong. If the constraints are defined to be > > INITIALLY DEFERRED, all you have to do is to wrap all the > > changes that put the database into a temporary inconsistent > > state into a transaction. What is a good idea and

Re: [SQL] Why can't I .........

2001-08-07 Thread Tom Lane
"Josh Berkus" <[EMAIL PROTECTED]> writes: >> -- use labels to name columns in this way >> >> ... select col1 userid, col2 name from ... (instead of using AS) > Because AS is the ANSI SQL 92 standard. And we like standards. Actually, SQL92 says that AS is optional. However, Postgres contains

Re: [SQL] Are circular REFERENCES possible ?

2001-08-07 Thread Tom Lane
Jan Wieck <[EMAIL PROTECTED]> writes: > The point is that we based our implementation of foreign keys > on the SQL3 specs. DEFERRED is not in SQL-92 AFAIK. I still have a concern about this --- sure, you can set up the circular references using ALTER TABLE, but will pg_dump dump them corr

Re: [SQL] Are circular REFERENCES possible ?

2001-08-07 Thread Jan Wieck
Tom Lane wrote: > Jan Wieck <[EMAIL PROTECTED]> writes: > > The point is that we based our implementation of foreign keys > > on the SQL3 specs. DEFERRED is not in SQL-92 AFAIK. > > I still have a concern about this --- sure, you can set up the circular > references using ALTER TABLE, but

[SQL] Name Alike Challenge

2001-08-07 Thread Josh Berkus
Folks, The "Name Alike" PL/pgSQL function has been posted on Roberto Mello's cookbook: http://www.brasileiro.net/postgres/cookbook/view-one-recipe.adp?recipe_id=967 This function requires Joe Conway's port of the Metaphone and Levenshtein functions to PostgreSQL, available from /contrib on CVS

Re: [SQL] Are circular REFERENCES possible ?

2001-08-07 Thread Josh Berkus
Jan, > All of this is wrong. If the constraints are defined to be > INITIALLY DEFERRED, all you have to do is to wrap all the > changes that put the database into a temporary inconsistent > state into a transaction. What is a good idea and strongly > advised anywa

Re: [SQL] Are circular REFERENCES possible ?

2001-08-07 Thread Jan Wieck
Josh Berkus wrote: > Denis, > > > I have a case where I wanted to do circular REFERENCES, is this > > impossible ? > > It can be done. It's just a bad idea. I don't see why it is a bad idea to apply the full business model to the database schema. > > Now, each shop REFERENCES a custom

Re: [SQL] Why can't I .........

2001-08-07 Thread Josh Berkus
Mounir, > -- do a join between two databases within the same installation. > > ... where db1.table1.userid = db2.table2.userid Because this is not supported on PostgreSQL. There are a number of reasons, and it may never be supported because there are drawbacks to allowing databases to referen

Re: [SQL] Are circular REFERENCES possible ?

2001-08-07 Thread Stephan Szabo
On Tue, 7 Aug 2001, Josh Berkus wrote: > Denis, > > > I have a case where I wanted to do circular REFERENCES, is this > > impossible ? > > It can be done. It's just a bad idea. > > > We deliver to the *shops* of our *customers*. > > We have therefore two tables : > > - customers (enterpris

Re: [SQL] Re: Adding an INTERVAL to a variable

2001-08-07 Thread Josh Berkus
Graham, > GC> SELECT Invoices.InvoiceDate + INTERVAL Acct.AverageDaysToPay > 'Days' Actually, all you're missing is some punctuation. Don't skimp on the :: and () ! Plus, you should use explicit CASTs wherever you remember them: SELECT Invoices.InvoiceDate + INTERVAL(CAST(Acct.AverageDaysToPa

Re: [SQL] Are circular REFERENCES possible ?

2001-08-07 Thread Gary Stainburn
Hi Denis, I've just had a similar experience with a 3-way circle. I have members, who belong in regions. Each region had a Regional Liasson Officer who was a member. I got round it by creating the three tables, but missing out one of the references - i.e. the one that links table 1 to tabl

[SQL] Why can't I .........

2001-08-07 Thread Mounir Benzid
-- do a join between two databases within the same installation. ... where db1.table1.userid = db2.table2.userid -- use labels to name columns in this way ... select col1 userid, col2 name from ... (instead of using AS) -- do an update with full referenced colomns ... update table1 set ta

[SQL] Re: Adding an INTERVAL to a variable

2001-08-07 Thread Vivek Khera
> "GC" == Graham Coates <[EMAIL PROTECTED]> writes: GC> SELECT Invoices.InvoiceDate + INTERVAL '41 Days' GC> works fine GC> but when trying to substitute the number of days with a value form a field GC> e.g. GC> SELECT Invoices.InvoiceDate + INTERVAL Acct.AverageDaysToPay 'Days' try SELE

Re: [SQL] Are circular REFERENCES possible ?

2001-08-07 Thread Josh Berkus
Denis, > I have a case where I wanted to do circular REFERENCES, is this > impossible ? It can be done. It's just a bad idea. > We deliver to the *shops* of our *customers*. > We have therefore two tables : > - customers (enterprise, financial information, and so on...) > - shop (with a na

Re: [SQL] Simple Insert Problem

2001-08-07 Thread Jan Wieck
[EMAIL PROTECTED] wrote: > Josh, > > Fuck you and the high horse you rode in on. Stop that language immediately! It is not accepted on any of our PostgreSQL mailing lists. > Yes as a matter of fact I did forget the quote marks. Do you think reading > that book will help with my silly sy

Re: [SQL] prob with PERL/Postgres

2001-08-07 Thread Thomas Good
On Mon, 6 Aug 2001, Tom Lane wrote: > Thomas Good <[EMAIL PROTECTED]> writes: > > Kate, he uses a diff module by the same author (Edmund Mergl) but with > > a very diff syntax. The advantage of the DBI - Kris, if you're > > interested - is that the syntax is much like ESQL/C and the code is > >

Re: [SQL] Are circular REFERENCES possible ?

2001-08-07 Thread David Lizano
> > >Which leads to : > >CREATE TABLE shops ( id_shop SERIAL PRIMARY KEY, id_cust integer >REFERENCES customers, ...) You can't reference to a table who doesn't exists still. >CREATE TABLE customers ( id_cust SERIAL PRIMARY KEY, id_defaultshop >integer REFERENCES shops, ...) Perhaps

Re: [SQL] Are circular REFERENCES possible ?

2001-08-07 Thread Grigoriy G. Vovk
Aug 7, 11:54 +0200, Denis Bucher wrote: > We deliver to the *shops* of our *customers*. > We have therefore two tables : > - customers (enterprise, financial information, and so on...) > - shop (with a name, street, phone number, name of manager) > > Now, each shop REFERENCES a customer so th

[SQL] Are circular REFERENCES possible ?

2001-08-07 Thread Denis Bucher
Hello ! I have a case where I wanted to do circular REFERENCES, is this impossible ? Just an example where it would be useful : We deliver to the *shops* of our *customers*. We have therefore two tables : - customers (enterprise, financial information, and so on...) - shop (with a name, st

RE: [SQL] Delete coloumn

2001-08-07 Thread Grigoriy G. Vovk
Aug 6, 23:35 -0500, Robby Slaughter wrote: > SELECT INTO it. Example: > > CREATE TABLE sample ( > id INTEGER, > data TEXT, > badcolumn DATE ); > > Now to delete the bad column table: > > CREATE TABLE sample_copy ( > id INTEGER, > data TEXT); > > and then copy it all over: > > SELECT