Re: [GENERAL] Rules on View

2016-03-01 Thread Tom Lane
Sridhar N Bamandlapally writes: > Is there a way to avoid creating rule under creation of view ? If you mean the ON SELECT rule, no. A view basically *is* an ON SELECT rule; there's not very much else to it. What usefulness do you imagine you'd get from a view without ON SELECT?

[GENERAL] Rules on View

2016-03-01 Thread Sridhar N Bamandlapally
Hi Is there a way to avoid creating rule under creation of view ? please let me know Thanks Sridhar

[GENERAL] rules

2015-02-26 Thread Ramesh T
it is in postgres i need to convert into oracle CREATE RULE payment_insert_p2007_04 AS ON INSERT TO payment WHERE (new.payment_date >= '2007-04-01'::timestamp without time zone) DO INSTEAD INSERT INTO payment_p2007_04 (payment_id)VALUES (1); in oracle format i used google i got BEGIN DBMS_MACAD

Re: [GENERAL] Rules on views - Changes from 8.4 to 9.1 ?

2013-01-28 Thread Adrian Klaver
On 01/28/2013 02:19 AM, Leif Jensen wrote: Hello. We have a system that has been running using PostgreSQL 8.4. We have now upgraded to PostgreSQL 9.1. The system has several rules on views and now most of these does not seem to work anymore. It is rather simple rules with mainly only

[GENERAL] Rules on views - Changes from 8.4 to 9.1 ?

2013-01-28 Thread Leif Jensen
Hello. We have a system that has been running using PostgreSQL 8.4. We have now upgraded to PostgreSQL 9.1. The system has several rules on views and now most of these does not seem to work anymore. It is rather simple rules with mainly only 1 replacement sql (update for 'on update' and i

Re: [GENERAL] Rules, Windows and ORDER BY

2012-08-24 Thread Tom Lane
Martijn van Oosterhout writes: > On Fri, Aug 24, 2012 at 09:32:32AM +, Jason Dusek wrote: >> Why are the individual indices not useful? The tests that the >> query does -- equality on key and realm and ordering on at -- >> are each supported by indices. Does it have to do with the cost >> of l

Re: [GENERAL] Rules, Windows and ORDER BY

2012-08-24 Thread Martijn van Oosterhout
On Fri, Aug 24, 2012 at 09:32:32AM +, Jason Dusek wrote: > 2012/8/23 Tom Lane : > > Jason Dusek writes: > >> CREATE TABLE kv > >> ( k bytea NOT NULL, > >> at timestamptz NOT NULL, > >> realm bytea NOT NULL, > >> v bytea NOT NULL ); > >> CREATE INDEX ON kv USING hash(k); > >>

Re: [GENERAL] Rules, Windows and ORDER BY

2012-08-24 Thread Jason Dusek
2012/8/23 Tom Lane : > Jason Dusek writes: >> I have a simple table of keys and values which periodically >> receives updated values. It's desirable to keep older values >> but, most of the time, we query only for the latest value of a >> particular key. > >> CREATE TABLE kv >> ( k bytea NOT N

Re: [GENERAL] Rules, Windows and ORDER BY

2012-08-23 Thread Tom Lane
Jason Dusek writes: > I have a simple table of keys and values which periodically > receives updated values. It's desirable to keep older values > but, most of the time, we query only for the latest value of a > particular key. > CREATE TABLE kv > ( k bytea NOT NULL, > at timestamptz NOT

[GENERAL] Rules, Windows and ORDER BY

2012-08-23 Thread Jason Dusek
Hello List, I have a simple table of keys and values which periodically receives updated values. It's desirable to keep older values but, most of the time, we query only for the latest value of a particular key. CREATE TABLE kv ( k bytea NOT NULL, at timestamptz NOT NULL, realm bytea

Re: [GENERAL] Rules of Thumb for Autovaccum

2012-02-15 Thread Ondrej Ivanič
Hi, On 16 February 2012 01:14, Robert James wrote: > What rules of thumb exist for: > * How often a table needs to be vacuumed? > * How often a table needs to be analyzed? > * How to tune Autovacuum? I prefer to use autovacuum daemon and sets thresholds on per table basis i.e. sets reasonable de

Re: [GENERAL] Rules of Thumb for Autovaccum

2012-02-15 Thread Robert James
Thanks. What about auto-analyze? When will they be analyzed by default? And what actions generally require new analyze? On 2/15/12, Bruce Momjian wrote: > On Wed, Feb 15, 2012 at 09:14:34AM -0500, Robert James wrote: >> What rules of thumb exist for: >> * How often a table needs to be vacuumed?

Re: [GENERAL] Rules of Thumb for Autovaccum

2012-02-15 Thread Bruce Momjian
On Wed, Feb 15, 2012 at 09:14:34AM -0500, Robert James wrote: > What rules of thumb exist for: > * How often a table needs to be vacuumed? > * How often a table needs to be analyzed? > * How to tune Autovacuum? > > I have a large DB server, and I'm concerned that it's not being > autovaccumed and

[GENERAL] Rules of Thumb for Autovaccum

2012-02-15 Thread Robert James
What rules of thumb exist for: * How often a table needs to be vacuumed? * How often a table needs to be analyzed? * How to tune Autovacuum? I have a large DB server, and I'm concerned that it's not being autovaccumed and autoanalyzed frequently enough. But I have no idea what proper values shoul

Re: [GENERAL] Rules going away

2011-09-30 Thread Gregg Jaskiewicz
You're right, rules are perfect for very limited and narrow cases. And make it very hard to write complicated queries against. (i.e., updates that only touch few columns, likewise with inserts). I'm guessing the upside is that rules are faster then triggers. -- Sent via pgsql-general mailing list

Re: [GENERAL] Rules going away

2011-09-30 Thread Igor Neyman
> -Original Message- > From: Gregg Jaskiewicz [mailto:gryz...@gmail.com] > Sent: Friday, September 30, 2011 5:18 AM > To: Igor Neyman > Cc: Ondrej Ivanič; pgsql-general@postgresql.org > Subject: Re: [GENERAL] Rules going away > > speaking of DO INSTEAD, for inser

Re: [GENERAL] Rules going away

2011-09-30 Thread Gregg Jaskiewicz
speaking of DO INSTEAD, for insert/update case. Try using RETURNING with that and rules ;) Good luck -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] Rules going away

2011-09-29 Thread Igor Neyman
> -Original Message- > From: Ondrej Ivanič [mailto:ondrej.iva...@gmail.com] > Sent: Wednesday, September 28, 2011 6:47 PM > To: pgsql-general@postgresql.org > Subject: Re: Rules going away > > Hi, > > > folks, don't use RULES! use triggers -- and as much as possible, keep > > triggers sim

Re: [GENERAL] Rules going away

2011-09-28 Thread Ondrej Ivanič
Hi, > folks, don't use RULES! use triggers -- and as much as possible, keep > triggers simple, short, and to the point (simple validation, custom > RI, auditing/logging, etc). I like them :). 'DO INSTEAD' rules are great for partitioning so you can insert (or update) to parent table and 'DO INSTE

Re: [GENERAL] Rules going away

2011-09-28 Thread Merlin Moncure
On Wed, Sep 28, 2011 at 10:53 AM, Rob Sargent wrote: > > > On 09/28/2011 08:34 AM, Tom Lane wrote: >> Andrew Sullivan writes: >>> On Wed, Sep 28, 2011 at 06:20:04AM -0700, David Fetter wrote: There's an even better reason not to use rules: they're going away in a not too distant version

Re: [GENERAL] Rules going away

2011-09-28 Thread Rob Sargent
On 09/28/2011 08:34 AM, Tom Lane wrote: > Andrew Sullivan writes: >> On Wed, Sep 28, 2011 at 06:20:04AM -0700, David Fetter wrote: >>> There's an even better reason not to use rules: they're going away in >>> a not too distant version of PostgreSQL. >> Really? How? I thought views were done us

Re: [GENERAL] Rules in views, how to?

2010-07-06 Thread Alban Hertroys
On 6 Jul 2010, at 13:03, Andre Lopes wrote: > Hi Alban, > > But in my application I have more than one way of uniquely identify the > record. Could be by the email field or by the id field. Unique is unique. There is no other record that could possibly be identified by the same unique identifi

Re: [GENERAL] Rules in views, how to?

2010-07-06 Thread Andre Lopes
Hi Alban, But in my application I have more than one way of uniquely identify the record. Could be by the email field or by the id field. Thera are update that are done by the WHERE email clause and other by the WHERE id clause. It is possible to deal with this? Best Regards, On Tue, Jul 6,

Re: [GENERAL] Rules in views, how to?

2010-07-06 Thread Alban Hertroys
On 6 Jul 2010, at 12:28, Andre Lopes wrote: > Now I need also to add an INSTEAD UPDATE rule and an INSTEAD DELETE rule, but > I have some doubts about it... let me explain... > > Ok, I need to create an INSTEAD UPDATE rule in this view, but I don't know > how to use the clause WHERE in the UPDA

[GENERAL] Rules in views, how to?

2010-07-06 Thread Andre Lopes
Hi, I'am using rules in views, but I'am not sure about how the rules work... let me explain... For example, I have this table: [code] CREATE TABLE "atau_utilizadores" ( "id" int4 NOT NULL, "group_id" int4 NOT NULL, "ip_address" char(16) NOT NULL, "username" varchar(50) NOT NULL,

[GENERAL] Rules in views, how to?

2010-07-06 Thread Andre Lopes
Hi, I'am using rules in views, but I'am not sure about how the rules work... let me explain... For example, I have this table: [code] CREATE TABLE "atau_utilizadores" ( "id" int4 NOT NULL, "group_id" int4 NOT NULL, "ip_address" char(16) NOT NULL, "username" varchar(50) NOT NULL,

Re: [GENERAL] Rules, triggers and such

2009-12-09 Thread Guillaume Lelarge
Le mercredi 9 décembre 2009 à 17:04:32, George Silva a écrit : > Hello all again :) > > I have a question: is it possible to replicate the behavior of a rule > INSTEAD of with a TRIGGER? > > For some specific reasons i need to use a trigger to update a > secondary table, but i don't want the chan

[GENERAL] Rules, triggers and such

2009-12-09 Thread George Silva
Hello all again :) I have a question: is it possible to replicate the behavior of a rule INSTEAD of with a TRIGGER? For some specific reasons i need to use a trigger to update a secondary table, but i don't want the changes to happen in the primary table too. Is it possible to do it? If so, how?

Re: [GENERAL] Rules and conditions

2009-12-09 Thread Guillaume Lelarge
Le mercredi 9 décembre 2009 à 12:38:33, George Silva a écrit : > Hello guys, > > Still having some trouble with this. > > I'm trying to use a case when, but postgres is still giving me syntax > error. > > CREATE OR REPLACE RULE instead_update AS ON UPDATE TO foo > DO INSTEAD > ( > CASE SELECT e

Re: [GENERAL] Rules and conditions

2009-12-09 Thread George Silva
Hello guys, Still having some trouble with this. I'm trying to use a case when, but postgres is still giving me syntax error. CREATE OR REPLACE RULE instead_update AS ON UPDATE TO foo DO INSTEAD ( CASE SELECT exists(SELECT 1 FROM versioning.foo_version_1 WHERE OLD.oid = NEW.oid) as a WHEN a=true

Re: [GENERAL] Rules and conditions

2009-12-09 Thread Leif Biberg Kristensen
On Wednesday 9. December 2009 09.06.12 Guillaume Lelarge wrote: > Le mercredi 9 décembre 2009 à 01:52:03, George Silva a écrit : > > [...] > > I can't seem to understand why a simples if is not working on the > > creation of rules. > > > > I tried both ways (am i missing something?): > > > > Sur

Re: [GENERAL] Rules and conditions

2009-12-09 Thread Guillaume Lelarge
Le mercredi 9 décembre 2009 à 01:52:03, George Silva a écrit : > [...] > I can't seem to understand why a simples if is not working on the > creation of rules. > > I tried both ways (am i missing something?): > Sure. IF does not exist in SQL, and you can only put SQL statements in a rule. Inste

[GENERAL] Rules and conditions

2009-12-08 Thread George Silva
Hello guys, I can't seem to understand why a simples if is not working on the creation of rules. I tried both ways (am i missing something?): Take a look: CREATE OR REPLACE RULE instead_update AS ON UPDATE TO foo DO INSTEAD ( IF exists(SELECT 1 FROM versioning.foo_version_1 WHERE oid =

Re: [GENERAL] Rules to provide a virtual column

2008-05-07 Thread Albe Laurenz *EXTERN*
James B. Byrne wrote: > The situation is this. A dependent table relationship is episodic. In other > words, a product might be available for a period of time, then not available, > then available again. Or, a firm might be a client for a period, then not, > then again. Or a person might be an

[GENERAL] Rules to provide a virtual column

2008-05-06 Thread James B. Byrne
This might be a little off topic and it may show a degree of naivety on my part but I have a small problem with coding a Ruby on Rails application and it seems to me that the best answer may reside in the database itself. The situation is this. A dependent table relationship is episodic. In othe

Re: [GENERAL] RULES and QUALIFICATION for INSERT

2008-03-27 Thread srdjan
Albe Laurenz wrote: srdjan wrote: What is the desired response to INSERT INTO vvv (name, town, num) VALUES ('Karl', 'Leipzig', 18); Should this generate an error message, do nothing, or insert something? In this case you shouldn't be able to do this insert. Should it generate

Re: [GENERAL] RULES and QUALIFICATION for INSERT

2008-03-27 Thread srdjan
Albe Laurenz wrote: srdjan wrote: I'll try to explain my problem with an example. -- I've got 2 tables and one view CREATE TABLE a (name varchar(20) primary key, num integer); CREATE TABLE b (town varchar(15), name varchar(20) references a(name)); CREATE VIEW vvv AS SELECT * FROM a NATUR

Re: [GENERAL] RULES and QUALIFICATION for INSERT

2008-03-26 Thread Albe Laurenz
srdjan wrote: >>> -- I've got 2 tables and one view >>> CREATE TABLE a (name varchar(20) primary key, num integer); >>> CREATE TABLE b (town varchar(15), name varchar(20) references a(name)); >>> >>> insert into a values ('tom',5); >>> insert into a values ('paul',99); >>> insert into a value

Re: [GENERAL] RULES and QUALIFICATION for INSERT

2008-03-26 Thread Albe Laurenz
srdjan wrote: >> What is the desired response to >> >> INSERT INTO vvv (name, town, num) VALUES ('Karl', 'Leipzig', 18); >> >> Should this generate an error message, do nothing, or insert something? > > In this case you shouldn't be able to do this insert. Should it generate an error message or

Re: [GENERAL] RULES and QUALIFICATION for INSERT

2008-03-26 Thread Albe Laurenz
srdjan wrote: > I'll try to explain my problem with an example. > > -- I've got 2 tables and one view > CREATE TABLE a (name varchar(20) primary key, num integer); > CREATE TABLE b (town varchar(15), name varchar(20) references a(name)); > > CREATE VIEW vvv AS SELECT * FROM a NATURAL JOIN b;

[GENERAL] RULES and QUALIFICATION for INSERT

2008-03-26 Thread srdjan
Hi to everyone. I'll try to explain my problem with an example. -- I've got 2 tables and one view CREATE TABLE a (name varchar(20) primary key, num integer); CREATE TABLE b (town varchar(15), name varchar(20) references a(name)); insert into a values ('tom',5); insert into a values ('paul',99);

Re: [GENERAL] Rules slower than Dynamic SQL ?

2007-12-06 Thread Decibel!
On Nov 26, 2007, at 6:09 PM, Simon Riggs wrote: On Mon, 2007-11-26 at 16:01 -0800, Alex Vinogradovs wrote: I've got a data warehouse with pretty high rate of insert into partitioned tables. What I've noticed, is that rule-based partitioning seems to be somewhat slower than insertions made dir

Re: [GENERAL] Rules slower than Dynamic SQL ?

2007-11-26 Thread Simon Riggs
On Mon, 2007-11-26 at 16:01 -0800, Alex Vinogradovs wrote: > I've got a data warehouse with pretty high rate of insert into > partitioned tables. What I've noticed, is that rule-based partitioning > seems to be somewhat slower than insertions made directly into > partitions through execution of dy

[GENERAL] Rules slower than Dynamic SQL ?

2007-11-26 Thread Alex Vinogradovs
Hi all, I've got a data warehouse with pretty high rate of insert into partitioned tables. What I've noticed, is that rule-based partitioning seems to be somewhat slower than insertions made directly into partitions through execution of dynamic SQL. Is it really true ? Thanks! Best regards,

Re: [GENERAL] rules and command status question

2007-09-25 Thread Alvaro Herrera
Josh Harrison escribió: > Hello, > I have a question in the postgres document chapter 34. Rules and Command > Status. > The last paragraph of that page says that > > "The programmer can ensure that any desired INSTEAD rule is the one that > sets the command status in the second case, by giving it

[GENERAL] rules and command status question

2007-09-25 Thread Josh Harrison
Hello, I have a question in the postgres document chapter 34. Rules and Command Status. The last paragraph of that page says that "The programmer can ensure that any desired INSTEAD rule is the one that sets the command status in the second case, by giving it the alphabetically last rule name amon

Re: [GENERAL] rules and rows affected

2007-08-30 Thread Tom Lane
"Roberto Icardi" <[EMAIL PROTECTED]> writes: > Everything works perfectly... BUT the query returns always 0 rows affected, > even if one record is inserted or deleted in friends_hobbies...why?? The rules for this are explained here: http://www.postgresql.org/docs/8.2/static/rules-status.html If

[GENERAL] rules and rows affected

2007-08-30 Thread Roberto Icardi
Hi all... I'm experimenting for the first time with rules to make a view updatable, but I've found a strange "effect"... I'll try to explain what I'm trying to achieve Suppose I have a table "friends" and a table "hobbies". Each friend can be interested in one or more hobbies: CREATE TABLE fr

[GENERAL] Rules / Triggers and Return Row Count

2006-09-10 Thread mj
I am attempting to accomplish a soft delete with a system using PostgreSQL, Hibernate, and EJB3(JBoss). I have set up tables with a column to indicate deleted state. What is the best way to accomplish this? I have looked into triggers and rules but end up with the same problem. How can I return to

Re: [GENERAL] rules: evaluate inputs in advance

2006-05-14 Thread Tom Lane
Martijn van Oosterhout writes: > Well, I notice that the SQL standard defines something called WITH, so > what you want is something like: > WITH OLD AS ( SELECT blah ) > DO > ( UPDATE > ; DELETE ) I think it'd be a mistake to assume that WITH would fix Markus' complaint. I haven't studied th

Re: [GENERAL] rules: evaluate inputs in advance

2006-05-14 Thread Martijn van Oosterhout
On Sun, May 14, 2006 at 08:01:39AM +0200, Markus Schiltknecht wrote: > > What you probably want is a function that is given the row and then > > executes the two statements on a per row basis. This has the effect you > > want but gives up the major benefit of rules, wholesale query > > restructurin

Re: [GENERAL] rules: evaluate inputs in advance

2006-05-13 Thread Markus Schiltknecht
Hi Martijn, On Fri, 2006-05-12 at 18:05 +0200, Martijn van Oosterhout wrote: > But it can't really. In the example that started this thread, there are > two seperate rules and after rewriting the executor will be presented > two seperate queries. Ah, thank you, that explains the difficulties with

Re: [GENERAL] rules: evaluate inputs in advance

2006-05-12 Thread Martijn van Oosterhout
On Fri, May 12, 2006 at 04:22:00PM +0200, Markus Schiltknecht wrote: > > There have been discussions about the problems > > Do you have some pointers here? I did not find relevant discussions in > the archives (of gmane.org) Hmm, maybe not so much discussions as comments from developers when the

Re: [GENERAL] rules: evaluate inputs in advance

2006-05-12 Thread Richard Broersma Jr
> Well, triggers cannot be used to create writeable views, can they? The documentation says that triggers can be used on views but only for Inserts; not updates or deletes. http://www.postgresql.org/docs/8.1/interactive/rules-triggers.html Regards, Richard ---(end of b

Re: [GENERAL] rules: evaluate inputs in advance

2006-05-12 Thread Markus Schiltknecht
On Fri, 2006-05-12 at 15:57 +0200, Martijn van Oosterhout wrote: > It's a known problem. It's also one of the reasons why triggers are > recommended over rules. And it's not desirable behaviour. Well, triggers cannot be used to create writeable views, can they? > There have been discussions about

Re: [GENERAL] rules: evaluate inputs in advance

2006-05-12 Thread Martijn van Oosterhout
On Fri, May 12, 2006 at 03:51:18PM +0200, Markus Schiltknecht wrote: > Hi, > > I was trying to create an updateable view. Suddenly I got foreign key > violations when using nextval('myseq'). > > As I understand, the rewriter does something similar to a simple text > replacement (I guess copying t

[GENERAL] rules: evaluate inputs in advance

2006-05-12 Thread Markus Schiltknecht
Hi, I was trying to create an updateable view. Suddenly I got foreign key violations when using nextval('myseq'). As I understand, the rewriter does something similar to a simple text replacement (I guess copying the plan tree nodes?) so that nextval gets evaluated again for every rule that appli

Re: [GENERAL] Rules on Select

2006-05-05 Thread elein
This is best done by using a trigger on the table. http://www.varlena.com/GeneralBits/38.php shows how to do it with both a trigger and with a rule. --elein [EMAIL PROTECTED] On Fri, May 05, 2006 at 04:48:28PM -0400, Sean Hamilton wrote: > I have to log each time a user selects data from a table

Re: [GENERAL] Rules on Select

2006-05-05 Thread Tony Wasson
On 5/5/06, Sean Hamilton <[EMAIL PROTECTED]> wrote: I have to log each time a user selects data from a table by inserting record in another table. For example I have table xzy user test selects id, name from table xyz. I want to insert into table xyz_log user, action, fields, timestamp test, sele

Re: [GENERAL] Rules on Select

2006-05-05 Thread Hogan, James F. Jr.
quot; To: , Subject: audit table containing Select statements submitted Date: Thu, 4 May 2006 12:45:59 -0500 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Sean Hamilton Sent: Friday, May 05, 2006 3:48 PM To: pgsql-general@postgresql.org Subject: [GENERAL

[GENERAL] Rules on Select

2006-05-05 Thread Sean Hamilton
I have to log each time a user selects data from a table by inserting record in another table. For example I have table xzy user test selects id, name from table xyz. I want to insert into table xyz_log user, action, fields, timestamp test, select, id name, 12/1/05 02:00:21 How can i do this u

Re: [GENERAL] Rules on 8.0.2

2006-01-11 Thread Michael Glaesemann
On Jan 11, 2006, at 21:15 , William Leite Araújo wrote: CREATE OR REPLACE RULE select_public_cliente AS ON SELECT TO public.cliente_tipo ERROR: event qualifications are not implemented for rules on SELECT As the error message indicates, RULEs are not applicable to ON SELECT. Use a vie

[GENERAL] Rules on 8.0.2

2006-01-11 Thread William Leite Araújo
Hi, I'm trying create the rule : CREATE OR REPLACE RULE select_public_cliente AS ON SELECT TO public.cliente_tipo   WHERE NOT EXISTS ( SELECT usesysid FROM pg_user left join pg_group on ( idx( grolist, usesysid ) > 0 )                          WHERE usename = current_user

Re: [GENERAL] Rules UPDATE

2005-08-22 Thread Gnanavel S
On 8/22/05, Pailloncy Jean-Gerard <[EMAIL PROTECTED]> wrote: Hi,With PostgreSQL 7.4.6.I have a table aaa (id serial, maj timestamp without time zone)I defined to function from_timestamp and to_timestamp to doconversion between text and timestamp with few checks and tricks. I defined a view aab (id

[GENERAL] Rules UPDATE

2005-08-22 Thread Pailloncy Jean-Gerard
Hi, With PostgreSQL 7.4.6. I have a table aaa (id serial, maj timestamp without time zone) I defined to function from_timestamp and to_timestamp to do conversion between text and timestamp with few checks and tricks. I defined a view aab (id serial, maj text) as "SELECT id, from_timestamp(

Re: [GENERAL] Rules vs Triggers

2005-07-29 Thread Randall Perry
Thanks for the info guys; got a better understanding now. -- Randall Perry sysTame Xserve Web Hosting/Co-location Website Development/Promotion Mac Consulting/Sales http://www.systame.com/ ---(end of broadcast)--- TIP 3: Have you checked our e

Re: [GENERAL] Rules vs Triggers

2005-07-27 Thread Janning Vygen
Am Dienstag, 26. Juli 2005 23:53 schrieb Randall Perry: > Read the Rules section of the manual and the section on Rules vs Triggers. > > From what I get triggers are necessary for column constraints. As far as > speed, it seems there are some differences between how fast rules/triggers > would do t

Re: [GENERAL] Rules vs Triggers

2005-07-26 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2005-07-26 17:53:35 -0400: > Read the Rules section of the manual and the section on Rules vs Triggers. > > From what I get triggers are necessary for column constraints. As far as > speed, it seems there are some differences between how fast rules/triggers > would do the sam

[GENERAL] Rules vs Triggers

2005-07-26 Thread Randall Perry
Read the Rules section of the manual and the section on Rules vs Triggers. >From what I get triggers are necessary for column constraints. As far as speed, it seems there are some differences between how fast rules/triggers would do the same action, but that some complex analysis is involved to de

[GENERAL] rules and table renaming

2005-06-29 Thread Teunis Peters
I'm renaming a table to a live database before it goes REALLY live and ends up on lots of servers. For various reasons I've got various different clients floating around and can't get them all updated synchronously. anyways. How do I make a set of rules to pass insert/update/delete/...

Re: [GENERAL] Rules on select

2005-01-17 Thread Rick Schumeyer
On Behalf Of Mariusz Czu³ada Sent: Monday, January 17, 2005 7:29 AM To: Postgres General Subject: [GENERAL] Rules on select Hi, I tried to create rule on a view. It should contain a WHERE clause. Unfortunately it does not work: a_4m=# CREATE RULE sharp_p1_rule AS ON SELECT TO sharp a_4m

[GENERAL] Rules on select

2005-01-17 Thread Mariusz Czułada
Hi, I tried to create rule on a view. It should contain a WHERE clause. Unfortunately it does not work: a_4m=# CREATE RULE sharp_p1_rule AS ON SELECT TO sharp a_4m-# WHERE part_key = 1 a_4m-# DO a_4m-# INSTEAD SELECT * FROM sharp_p1; ERROR: ON SELECT rule may not use OLD a_4m=# CREATE RU

Re: [GENERAL] Rules

2004-12-06 Thread Michael Fuhr
On Mon, Dec 06, 2004 at 04:15:54PM +1100, Jamie Deppeler wrote: > i have a join table eg > > primarykey > field1 > field2 > > and based on SQL Select have the values of field1 inserted into a new > table which will scroll which will launch a trigger but im having > problems getting this to wor

[GENERAL] Rules

2004-12-05 Thread Jamie Deppeler
Hi, What i am trying to do is i have a join table eg primarykey field1 field2 and based on SQL Select have the values of field1 inserted into a new table which will scroll which will launch a trigger but im having problems getting this to work? Any ideas anyone? sql select may return 1 or more r

Re: [GENERAL] Rules

2004-12-02 Thread Berend Tober
>> Planning on witting a rule for a view, and i was wondering if anyone >> could suggest a good Internet resource? > > http://www.postgresql.org > > (Sorry, couldn't resist.) > But here is a simple working example of making a view updatable: CREATE TABLE consumable ( consumable_pk serial NOT

Re: [GENERAL] Rules

2004-12-02 Thread Berend Tober
> Planning on witting a rule for a view, and i was wondering if anyone > could suggest a good Internet resource? http://www.postgresql.org (Sorry, couldn't resist.) ---(end of broadcast)--- TIP 7: don't forget to increase your free space map sett

Re: [GENERAL] Rules

2004-12-02 Thread Terry Lee Tucker
Have you looked at the html docs? It looks like "34.2. Views and the Rule System" might be what you are looking for, but I didn't check it closely. On Thursday 02 December 2004 05:34 pm, Jamie Deppeler saith: > HI, > > Planning on witting a rule for a view, and i was wondering if anyone > could s

[GENERAL] Rules

2004-12-02 Thread Jamie Deppeler
HI, Planning on witting a rule for a view, and i was wondering if anyone could suggest a good Internet resource? thx begin:vcard fn:Jamie Deppeler n:Deppeler;Jamie org:Once;Development adr:;;46 Roseneath Street;North Geelong;Vic;3215;Australia email;internet:[EMAIL PROTECTED] title:Database Admin

Re: [GENERAL] rules

2004-11-25 Thread Daniel Martini
Hi, Citing Jamie Deppeler <[EMAIL PROTECTED]>: > sample sql querty > > INSERT INTO schema.table2 > ( > "field1", > "field2", > "field3", > "field4", > "field5", > "field6", > "field7", > "field8", > "field9", > ) > VALUES > ( > SELECT >

[GENERAL] rules

2004-11-25 Thread Jamie Deppeler
This may be a bit of stupid question but it is the first time i have played around with rules and i am trying to convert a sql statement into a rule sample sql querty INSERT INTO schema.table2 ( "field1", "field2", "field3", "field4", "field5", "field6", "field7",

Re: [GENERAL] Rules WHERE condition

2004-11-17 Thread Robert Fitzpatrick
On Wed, 2004-11-17 at 12:49, Robert Fitzpatrick wrote: > On Wed, 2004-11-17 at 11:49, Michael Fuhr wrote: > > On Wed, Nov 17, 2004 at 11:20:41AM -0500, Robert Fitzpatrick wrote: > > > > > I have a view that used union all to merge three tables together. I was > > > hoping to create a rule, one for

Re: [GENERAL] Rules WHERE condition

2004-11-17 Thread Robert Fitzpatrick
On Wed, 2004-11-17 at 11:49, Michael Fuhr wrote: > On Wed, Nov 17, 2004 at 11:20:41AM -0500, Robert Fitzpatrick wrote: > > > I have a view that used union all to merge three tables together. I was > > hoping to create a rule, one for each table using the WHERE condition of > > the rule to determin

Re: [GENERAL] Rules WHERE condition

2004-11-17 Thread Michael Fuhr
On Wed, Nov 17, 2004 at 11:20:41AM -0500, Robert Fitzpatrick wrote: > I have a view that used union all to merge three tables together. I was > hoping to create a rule, one for each table using the WHERE condition of > the rule to determine which table gets updated. Is this possible? See the CREA

[GENERAL] Rules WHERE condition

2004-11-17 Thread Robert Fitzpatrick
I have a view that used union all to merge three tables together. I was hoping to create a rule, one for each table using the WHERE condition of the rule to determine which table gets updated. Is this possible? This is what I have, assume the view here is a merge of three tables using union all:

[GENERAL] Rules and locking within a transaction?...

2004-10-09 Thread Net Virtual Mailing Lists
Hello, If I have a rule like this: CREATE OR REPLACE RULE sometable_update AS ON UPDATE TO table2 DO UPDATE cache SET updated_dt=NULL WHERE tablename='sometable'; CREATE OR REPLACE RULE sometable_insert AS ON INSERT TO table2 DO UPDATE cache SET updated_dt=NULL WHERE tablename='sometable'; CREAT

[GENERAL] Rules question

2003-09-15 Thread Adam Kavan
I am starting to work with rules. I think I have them down but the folowing one is giving me grief. It tells me that it has rewritten 100 times and probably has looped. The columns ID and Location make up the primary key so I am sure that the result update should only effect one row. Anyone

[GENERAL] Rules, views, sequences and returned values

2001-03-23 Thread DaVinci
Hello. Only a question. I have a table and want to make a view updateable with rules. Table has a sequence that creates default value to primary key when inserting. And now the question: Is it posible to return value of primary key from rule of inserting with NEW? Is that value what i would

[GENERAL] Rules

2001-01-30 Thread Nelio Alves Pereira Filho
I'd like to know in what order are rules executed, comparing to the queries that generated them. For instance, supose that a INSERT on table A has a rule to update a column in table B. What will be executed first: the INSERT or UPDATE? Tks -- Nelio Alves Pereira Filho IFX Networks - www.ifx.com

Re: [GENERAL] rules *very* slow?

2000-10-19 Thread Neil Conway
After my last email, I added the rest of the rule actions. So the relevant part of the schema now looks like this: CREATE RULE update_msg_stats AS ON INSERT TO messages DO ( UPDATE users SET num_posts = num_posts + 1 WHERE users.id = new.poster; UPDATE threads SET

Re: [GENERAL] rules *very* slow?

2000-10-18 Thread Tom Lane
Neil Conway <[EMAIL PROTECTED]> writes: > I would expect the rule it cause a bit of overhead (maybe > taking twice or three times as long as w/o the rule), but > it's taking ~52x longer. Ouch. > I've tried creating an index on messages.poster, but it has > no effect (performance is the same). I

[GENERAL] rules *very* slow?

2000-10-18 Thread Neil Conway
In testing my database, I've encountered what appears to be a concerning performance problem using a rule (ON INSERT). Here's the situation: Every time a row is inserted into a table (called 'messages'), I want to increment a counter in a different table (called 'users'). The best way I could thi

Re: [GENERAL] rules on INSERT can't UPDATE new instance?

2000-06-13 Thread Tom Lane
Bruce Momjian <[EMAIL PROTECTED]> writes: > Is the INSERT rule re-ordering mentioned a TODO item? Darn if I know. I threw the thought out for discussion, but didn't see any comments. I'm not in a hurry to change it, unless there's consensus that we should. regards, tom

Re: [GENERAL] rules on INSERT can't UPDATE new instance?

2000-06-13 Thread Bruce Momjian
Is the INSERT rule re-ordering mentioned a TODO item? > Bruce Momjian <[EMAIL PROTECTED]> writes: > > I thought an INSERT rule with an UPDATE action would work on the same > > table, but that fails. Seems the rule is firing before the INSERT > > happens. > > Yes, a trigger is the right way to d

Re: [GENERAL] rules on INSERT can't UPDATE new instance?

2000-05-21 Thread Bruce Momjian
> Bruce Momjian <[EMAIL PROTECTED]> writes: > > I thought an INSERT rule with an UPDATE action would work on the same > > table, but that fails. Seems the rule is firing before the INSERT > > happens. > > Yes, a trigger is the right way to do surgery on a tuple before it is > stored. Rules are

Re: [GENERAL] rules on INSERT can't UPDATE new instance?

2000-05-20 Thread Stephan Szabo
ECTED]> To: <[EMAIL PROTECTED]> Sent: Saturday, May 20, 2000 2:00 AM Subject: [GENERAL] rules on INSERT can't UPDATE new instance? > > From the create_rule man page this example is offered: > > CREATE RULE example_5 AS >ON INERT TO emp WHERE new.salary >

[GENERAL] rules on INSERT can't UPDATE new instance?

2000-05-20 Thread Louis-David Mitterrand
From the create_rule man page this example is offered: CREATE RULE example_5 AS ON INERT TO emp WHERE new.salary > 5000 DO UPDATE NEWSET SET salary = 5000; But what is "NEWSET"? Is it a keyword? My problem is that on an insert with an invalid amount I try t

[GENERAL] Rules, triggers, ??? - What is the best way to enforce data-validation tests?

2000-01-12 Thread Greg Youngblood
I am in the process of creating a large relational database. One of the key things I need to include in this database is a system to maintain data integrity across multiple tables. here's an example: Table: items item_id description vendor_id model cost stuff1

[GENERAL] rules - optimizing

1998-12-16 Thread Marcin Grondecki
Hi ppl I've started to use rules. Something strange with one of them: AIX 4.1 PostgreSQL 6.4 create word_list (id int4, word char(15), count int4 default 0); CREATE create unique index word_list_word_uidx on word_list (word); CREATE ... (something inserted into word_list) create table temp (word