Re: [SQL] Referencing external table in update/insert triggers

2010-02-18 Thread Amitabh Kant
On Thu, Feb 18, 2010 at 2:53 PM, Richard Huxton wrote: > On 17/02/10 15:18, Amitabh Kant wrote: > >> >> CREATE OR REPLACE FUNCTION update_data() RETURNS TRIGGER AS $update_data$ >> BEGIN >> IF NEW.t1f4> t2.t2f4 >> UPDATE t2 set t2f2=NEW.t1f2, t2f3=NEW.t1f3, t2f4=NEW.t1f4 where >> t2f

Re: [SQL] Referencing external table in update/insert triggers

2010-02-18 Thread Richard Huxton
On 17/02/10 15:18, Amitabh Kant wrote: CREATE OR REPLACE FUNCTION update_data() RETURNS TRIGGER AS $update_data$ BEGIN IF NEW.t1f4> t2.t2f4 UPDATE t2 set t2f2=NEW.t1f2, t2f3=NEW.t1f3, t2f4=NEW.t1f4 where t2f1=NEW.d1; RETURN NEW; END IF; END; $update_data$ LANGUAGE pl

[SQL] Referencing external table in update/insert triggers

2010-02-17 Thread Amitabh Kant
Hi I have the following table structure for which I am trying to set a AFTER INSERT or UPDATE trigger: CREATE OR REPLACE FUNCTION update_data() RETURNS TRIGGER AS $update_data$ BEGIN IF NEW.t1f4 > t2.t2f4 UPDATE t2 set t2f2=NEW.t1f2, t2f3=NEW.t1f3, t2f4=NEW.t1f4 where t2f1=NEW.d1;

[SQL] Referencing tables are grinding UPDATE to a halt

2007-01-15 Thread William Scott Jordan
Hey all! I'm having some trouble with a simple update on a table that only has about 250,000 rows in it. The table itself looks something like: CREATE TABLE price_details ( price_detail_id int PRIMARY KEY, private bool ) ; There is one table that references price_details, but isn't affected

Re: Fwd: Re: [SQL] Referencing

2005-11-01 Thread Daryl Richter
[EMAIL PROTECTED] wrote: Quoting Daryl Richter <[EMAIL PROTECTED]>: [EMAIL PROTECTED] wrote: > Quoting Daryl Richter <[EMAIL PROTECTED]>: >> It's hard to say without knowing more precisely what you are trying to >> model, but I think this push you in the right direction: >> > Okay, but referenc

Re: Fwd: Re: [SQL] Referencing

2005-10-31 Thread lucas
Quoting Daryl Richter <[EMAIL PROTECTED]>: [EMAIL PROTECTED] wrote: > Quoting Daryl Richter <[EMAIL PROTECTED]>: >> It's hard to say without knowing more precisely what you are trying to >> model, but I think this push you in the right direction: >> > Okay, but references between (output/input) a

Re: Fwd: Re: [SQL] Referencing

2005-10-31 Thread Daryl Richter
[EMAIL PROTECTED] wrote: > Quoting Daryl Richter <[EMAIL PROTECTED]>: > >> It's hard to say without knowing more precisely what you are trying to >> model, but I think this push you in the right direction: >> [snipped old schema] > > Okay, but references between (output/input) and ACTIVITY table

Re: Fwd: Re: [SQL] Referencing

2005-10-28 Thread lucas
Quoting Daryl Richter <[EMAIL PROTECTED]>: It's hard to say without knowing more precisely what you are trying to model, but I think this push you in the right direction: -- This table takes the place of both SEND and BUY create table activity( id serial primary key, prod

Re: Fwd: Re: [SQL] Referencing

2005-10-28 Thread Daryl Richter
[EMAIL PROTECTED] wrote: Ok, But the problem is becouse the "buy" and "send" tables referencing with other father table, wich is different. I shoud not create a spent table to put the "buy" and "send" values becouse the entire database is more complex than it. look: create table output( id seria

Fwd: Re: [SQL] Referencing

2005-10-28 Thread lucas
Ok, But the problem is becouse the "buy" and "send" tables referencing with other father table, wich is different. I shoud not create a spent table to put the "buy" and "send" values becouse the entire database is more complex than it. look: create table output( id serial primary key, client integ

[SQL] Referencing

2005-10-27 Thread lucas
Hi. Is there a way to references dynamic tables? I.E: I have a table called "buy" that create some records in "financial" table, but there is other table called "send" that create other records in "financial". "Financial" table have the moneys' movements and needs to be referenciable by "buy or sen

Re: [SQL] referencing oid impozsible ?

2001-09-11 Thread Josh Berkus
Patrick, > I tried recently (pgsql 7.1.2) to establish the oid of one table as > foreign key > in another. > To no avail : there was no uniqueness constraint on that column > Naturally, it seems impossible to add a uniqueness constraint to such > a system > column. > As far as i know, the oid

Re: [SQL] referencing oid impozsible ?

2001-09-11 Thread Stephan Szabo
On Tue, 11 Sep 2001 [EMAIL PROTECTED] wrote: > hello all > I tried recently (pgsql 7.1.2) to establish the oid of one table as foreign key > in another. > To no avail : there was no uniqueness constraint on that column > Naturally, it seems impossible to add a uniqueness constraint to such a sys

[SQL] referencing oid impozsible ?

2001-09-11 Thread patrick . jacquot
hello all I tried recently (pgsql 7.1.2) to establish the oid of one table as foreign key in another. To no avail : there was no uniqueness constraint on that column Naturally, it seems impossible to add a uniqueness constraint to such a system column. As far as i know, the oid is by nature uniqu

Re: [SQL] Referencing named attribute in where clause doesn't workwith 7.1.2?

2001-08-08 Thread Peter Eisentraut
Andreas Joseph Krogh writes: > Hi, this is my first post to this list so please... > I have problems getting this query to work, any ideas? > > select article.title_text_key, > (select on_text.text_value from on_text where > on_text.text_key = title_text_key > AND NOT title_text_key i

Re: [SQL] Referencing named attribute in where clause doesn't workwith 7.1.2?

2001-08-08 Thread Andreas Joseph Krogh
Thomas Good wrote: > > On Wed, 8 Aug 2001, Andreas Joseph Krogh wrote: > > > Hi, this is my first post to this list so please... > > I have problems getting this query to work, any ideas? > > > > select article.title_text_key, > > (select on_text.text_value from on_text where > > on_text.t

Re: [SQL] Referencing named attribute in where clause doesn't workwith 7.1.2?

2001-08-08 Thread Thomas Good
On Wed, 8 Aug 2001, Andreas Joseph Krogh wrote: > Hi, this is my first post to this list so please... > I have problems getting this query to work, any ideas? > > select article.title_text_key, > (select on_text.text_value from on_text where > on_text.text_key = title_text_key > AND

[SQL] Referencing named attribute in where clause doesn't work with 7.1.2?

2001-08-08 Thread Andreas Joseph Krogh
Hi, this is my first post to this list so please... I have problems getting this query to work, any ideas? select article.title_text_key, (select on_text.text_value from on_text where on_text.text_key = title_text_key AND NOT title_text_key is NULL AND on_text.lang_id = (s

Re: [SQL] Referencing a view?

2001-07-13 Thread Josh Berkus
James, > However, I came to the realization that if somebody changes their > address, I > don't want it to be changed on previous orders. So I think i'll > change the > orders table to contain the actual address information and use an > INSERT ... > SELECT instead. That way I can be sure I have

Re: [SQL] Referencing a view?

2001-07-13 Thread Grigoriy G. Vovk
Jul 13, 09:41 -0400, James Orr wrote: > Thanks for all the responses! The one from Grigoriy was particularly > interesting, I hadn't thought of that approach. > > However, I came to the realization that if somebody changes their address, I > don't want it to be changed on previous orders. So I

Re: [SQL] Referencing a view?

2001-07-13 Thread James Orr
Thanks for all the responses! The one from Grigoriy was particularly interesting, I hadn't thought of that approach. However, I came to the realization that if somebody changes their address, I don't want it to be changed on previous orders. So I think i'll change the orders table to contain th

Re: [SQL] Referencing a view?

2001-07-13 Thread Grigoriy G. Vovk
Jul 12, 16:25 -0400, James Orr wrote: Much better will be change database structure - you have absolutely identical tables, so is not good from normalization point of view. Better use one table for address, and link it to one table for "entity" - both person and company, and "entity" link to spec

Re: [SQL] Referencing a view?

2001-07-12 Thread Stephan Szabo
On Thu, 12 Jul 2001, James Orr wrote: > Hi, > > Is there anyway that you can reference a column in a view for > referential integrity? The problem is with the unique thing, > obviously I can't create a unique index on a view. Here is what I > have: Not right now, and actually you still wouldn

[SQL] Referencing a view?

2001-07-12 Thread James Orr
Hi,   Is there anyway that you can reference a column in a view for referential integrity?  The problem is with the unique thing, obviously I can't create a unique index on a view.  Here is what I have: CREATE SEQUENCE "addresses_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1  c

Re: [SQL] referencing serials

2000-07-21 Thread Emils Klotins
On 21 Jul 2000, at 9:41, Markus Wagner wrote: > which data type should be used to hold references to SERIALs in external > tables? integer I believe. Actually if you \d a table with a serial you'll see that it's an integer with DEFAULT clause specified.

[SQL] referencing serials

2000-07-21 Thread Markus Wagner
Hello, which data type should be used to hold references to SERIALs in external tables? I tried to use SERIAL, but then a sequence is created for the referencing table. Markus