Re: [SQL] Create Public Schema

2005-11-20 Thread Andreas Kretschmer
[EMAIL PROTECTED] [EMAIL PROTECTED] schrieb: Hello all, I'm trying to create a schema that contains the default tables, functions, etc. of the public schema. Using pgAdmin, when I create a schema, it is blank 1. make a dump from the public-schema 2. edit the dump and change 'public' to

[SQL] Trigger / rule question

2005-11-20 Thread Joost Kraaijeveld
Hi, Are a trigger or rule part of a query, that is: 1. Does an insert, update or delete statement return before or after an After trigger (is such a trigger or rule synchronous or a-synchronous? 2. Is there a concept of a rule or trigger that fails? If so, if a trigger or rule fails, does the

Re: [SQL] Create Public Schema

2005-11-20 Thread Mario Splivalo
On Sat, 2005-11-19 at 20:03 -0700, [EMAIL PROTECTED] wrote: Hello all, I'm trying to create a schema that contains the default tables, functions, etc. of the public schema. Using pgAdmin, when I create a schema, it is blank - has no associated aggregates, tables, etc. How would I create

Re: [SQL] Is it possible to redirect an update/insert/delete to a different table?

2005-11-20 Thread Peter Eisentraut
Andy Ballingall wrote: I've looked through rules, and as far as I can make out, they are only useful for explicit actions. I'm looking for something that behaves as though it simply substitutes the table name for a different table name before executing the command, no matter what the command

Re: [SQL] Trigger / rule question

2005-11-20 Thread Peter Eisentraut
Joost Kraaijeveld wrote: 1. Does an insert, update or delete statement return before or after an After trigger (is such a trigger or rule synchronous or a-synchronous? Synchronous 2. Is there a concept of a rule or trigger that fails? If so, if a trigger or rule fails, does the insert,

Re: [SQL] Is it possible to redirect an update/insert/delete to a different table?

2005-11-20 Thread Jaime Casanova
I've looked through rules, and as far as I can make out, they are only useful for explicit actions. I'm looking for something that behaves as though it simply substitutes the table name for a different table name before executing the command, no matter what the command looks like. Make 3

Re: [SQL] Is it possible to redirect an update/insert/delete to a different table?

2005-11-20 Thread Andy Ballingall
Hello Peter, I'm glad it's possible, but I can't see how from the documentation. Say if I have a table called 'apples' and a table called 'pears'. What would the rule look like that would remap all updates on apples so that they were applied to pears instead? Thanks, Andy

Re: [SQL] Trigger / rule question

2005-11-20 Thread Joost Kraaijeveld
Hi Peter, On Sun, 2005-11-20 at 12:08 +0100, Peter Eisentraut wrote: Joost Kraaijeveld wrote: 1. Does an insert, update or delete statement return before or after an After trigger (is such a trigger or rule synchronous or a-synchronous? Synchronous 2. Is there a concept of a rule or

Re: [SQL] Is it possible to redirect an update/insert/delete to a different table?

2005-11-20 Thread Andy Ballingall
Hello Jaime, I'm still not quite clear. Say I have a number of different updates on a table 'apples' in my code, including: UPDATE apples set pips=6 and color='yellow' where id=3; UPDATE apples set size=10 where id=6; What would a rule look like which, when *any* update is attempted on the

Re: [SQL] Is it possible to redirect an update/insert/delete to a different table?

2005-11-20 Thread Andreas Kretschmer
Andy Ballingall [EMAIL PROTECTED] schrieb: Hello Peter, I'm glad it's possible, but I can't see how from the documentation. Say if I have a table called 'apples' and a table called 'pears'. What would the rule look like that would remap all updates on apples so that they were applied

Re: [SQL] Is it possible to redirect an update/insert/delete to a different table?

2005-11-20 Thread Andreas Kretschmer
Andy Ballingall [EMAIL PROTECTED] schrieb: Hello Jaime, I'm still not quite clear. Say I have a number of different updates on a table 'apples' in my code, including: UPDATE apples set pips=6 and color='yellow' where id=3; UPDATE apples set size=10 where id=6; What would a rule

Re: [SQL] Is it possible to redirect an update/insert/delete to a different table?

2005-11-20 Thread Andy Ballingall
Hi Andreas, The rule you've given only works for an update which changes the name. If I do another update which changed the colour instead of the name, that rule wouldn't do the right thing. Instead, I'm looking for something which, with a single 'rule' (or whatever the mechanism ends up

Re: [SQL] Is it possible to redirect an update/insert/delete to a different table?

2005-11-20 Thread Andreas Kretschmer
Andy Ballingall [EMAIL PROTECTED] schrieb: Hi Andreas, The rule you've given only works for an update which changes the name. If I do another update which changed the colour instead of the name, that rule wouldn't do the right thing. Right. Instead, I'm looking for something which,

Re: [SQL] Is it possible to redirect an update/insert/delete to a different table?

2005-11-20 Thread Andy Ballingall
Try it. [snipped example] Ah. Basically, you set up the rule to assign every column, and if the update doesn't redefine some columns, then it still works. I didn't understand that you could get the rule to work generically like this. I'll presume that the rule will need amending if the table

[SQL] Please help to wite the constraint.

2005-11-20 Thread Grigory O. Ptashko
Hello, everybody! I don't whether it is possible to do the following but anyway I can't. I need to write a constraint as described below. Here are four tables: CREATE TABLE countries (id SERIAL, name VARCHAR(255), PRIMARY KEY (id) ); CREATE TABLE countries_names (id INT NOT NULL, id_lang

Re: [SQL] Is it possible to redirect an update/insert/delete to a different table?

2005-11-20 Thread Adrian Klaver
On Sunday 20 November 2005 09:15 am, Andy Ballingall wrote: It works because of the way updates are done. When you do an update two versions of the row exist. The OLD version is the row as it existed before you updated. The NEW version contains the entire version with the update changes. The