[GENERAL] Triggers

2004-11-28 Thread Jamie Deppeler
Hi, Just doing some testing at the moment and trying to make a trigger that consists of a insert statement which as a result of an sql querty! Is this possible? if so could someone give me some pointers as i am having no luck trying to get this to work, have even tried this but still doesnt wor

[GENERAL] Triggers

2006-10-15 Thread Germán Hüttemann Arza
Hello, I have this doubt since I started using PostgreSQL, a few months ago.Why triggers are defined that way? I mean, in others DBMS you simply write:CREATE TRIGGER ... bla bla bla BEGIN  END;Why you should write a function first and then the trigger, which must call that function?What are th

[GENERAL] triggers

2009-04-16 Thread Gustavo Rosso
Gente, buenos dias. Como consulto lo triggers desde psql? Gracias! -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

[GENERAL] TRIGGERS

1998-06-04 Thread Jose' Soares Da Silva
Hi, all! I am trying to create a trigger to update a field on a "son" table when a linked field (foreign key) is modified on a table "father". example: table son: table father: - id /-< id description

[GENERAL] Triggers ?

1999-04-26 Thread Sergei Chernev
Hello, I have postgresql 6.4.2 on bsdi3.1 here is one problem with triggers: ser=> select updater(); updater --- t (1 row) ser=> \df updater result|function|arguments|description --++-+--- bool |updater | | (1 row) ser=> CREATE TRIGGER daemon_singleton B

[GENERAL] Triggers inherited?

2007-02-22 Thread Bertram Scharpf
Hi, it is very inconvenient for me that triggers aren't inherited: create table watch ( mod timestamp with time zone default '-infinity' not null ); create function update_mod() returns trigger ... create trigger update_mod before insert or update on watch for each row e

[GENERAL] triggers/constraints?

2005-10-08 Thread ako...
hello, consider a sample table: create table item (id serial, parent_id int, path varchar(256)); "id" is a unique identifier of each row, "parent_id" is an id of another row in the same table or null what is the right way in postgresql to ensure that the "path" field of a given row is a prefix

[GENERAL] Triggers & inheritance

2007-09-28 Thread Scott Ribe
Triggers have never been inherited, right? Not in any version? I'm pretty sure that's the case, but I'm debugging some old logging and just need to confirm it. -- Scott Ribe [EMAIL PROTECTED] http://www.killerbytes.com/ (303) 722-0567 voice ---(end of broadcast)---

Re: [GENERAL] Triggers

2004-11-29 Thread Richard Huxton
Jamie Deppeler wrote: Hi, Just doing some testing at the moment and trying to make a trigger that consists of a insert statement which as a result of an sql querty! Look into using EXECUTE - it accepts a string expression and executes it. Don't forget to use the quote_xxx() functions to quote ide

[GENERAL] Triggers, again.. ;-)

2005-02-19 Thread Net Virtual Mailing Lists
Hello, I have asked about this before, but I just haven't been able to get anywhere with it yet.. I'm hoping someone can help me? Here is my original function and trigger: CREATE OR REPLACE VIEW items_category AS select count(*) AS count ,b.category,nlevel(b.category) AS level, subpath(b.cate

Re: [GENERAL] Triggers

2006-10-15 Thread Chris Mair
> Why you should write a function first and then the trigger, which must > call that function? > > What are the advantages/disadvantages of that? Where can I find more > information? The PG way seems very natural to me: you can write functions that do something and then have many triggers call t

Re: [GENERAL] Triggers

2006-10-15 Thread Tom Lane
Chris Mair <[EMAIL PROTECTED]> writes: >> Why you should write a function first and then the trigger, which must >> call that function? > ... there's not just PL/PGSQL: you might want > to define a function in C or Perl and then have a trigger call it. Right, that's the real reason: this approach

[GENERAL] Triggers question

2006-03-01 Thread ycrux
Hi All!I want to setup a trigger capable to return more than one record.Example (table users contains 10 records):CREATE FUNCTION get_users() RETURNS SOME_TYPE AS 'BEGIN   return (SELECT * FROM users);' LANGUAGE 'plpgsql';I can't figure out the correct Postgres type for SOME_TYPE (see above

Re: [GENERAL] triggers

2009-04-17 Thread Yuriy Rusinov
Hello Gustavo ! > Gente, buenos dias. > Como consulto lo triggers desde psql? > Unfortunately I don't know Spanish. As far as I understand your question was about triggers in postgresql. Trigger is the function calls automatically on operations insert-delete-update. -- Best regards, Sincerely y

[GENERAL] triggers & functions

2000-01-12 Thread Sarah Officer
Hi, I'm porting a database from Oracle, and I'm having difficulty working out the syntax & logic for porting the triggers. Here's an example of what I have in Oracle: create table Images ( id varchar(100) PRIMARY KEY, title varchar(25)NOT NULL, filepath va

Re: [GENERAL] Triggers

2000-09-22 Thread Stephan Szabo
On Fri, 22 Sep 2000, Enrico Comini wrote: > Question > If have a table with a primary key and another table with outer key > referenced on the primary of the first table. > If I want list the active triggers how i have to do ? select * from pg_trigger; > If I delete de first table I have the m

[GENERAL] Triggers again

2001-09-28 Thread Mihai Gheorghiu
1) I have some TRIGGER BEFORE INSERT created explicitly, and other(s) created implicitly, through default constraints. What is their execution order? 2) Are the changes made by the first visible to the following ones? ---(end of broadcast)--- TIP 5

Re: [GENERAL] triggers

2001-10-10 Thread Thalis A. Kalfigopoulos
> I started looking at the trigger support in PostgreSQL and found what I > needed except I'm not sure how to write the "body" of the trigger. In > Oracle I write PL/SQL but it seems I may have to write C code on the > PostgreSQL side. Is this true? Is there a PostgreSQL procedural language > t

[GENERAL] Triggers tutorial

2003-10-15 Thread Nagib Abi Fadel
Hi, is there any good trigger tutorial on the net ?? thx __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com ---(end of broadcast)--- TIP 9: the planner will ignore you

[GENERAL] triggers and TriggerData

2007-01-21 Thread gustavo halperin
First, thank you for your answers about my problem with the function 'CREATE TRIGGER', I have another question about triggers, how can I pass arguments ?? I read about some struct TriggerData *CurrentTriggerData, but I didn't found any explanation or example about how to use it in postgres SQL.

Re: [GENERAL] Triggers inherited?

2007-02-22 Thread Richard Huxton
Bertram Scharpf wrote: Hi, it is very inconvenient for me that triggers aren't inherited: Foreign keys too (which are a special type of trigger of course). Is this behaviour to be implemented at any point of time in the future? Could it be advisible to write the patch? Or is it just too easy

Re: [GENERAL] Triggers inherited?

2007-02-23 Thread Marc Evans
Hi - I too have encountered this issue. The work around that I created was to have every table have a set of 3 cooresponding functions that know how to 1) create the table; 2) create triggers for the table; 3) create indexes for the table. By doing so, I then am able to use a lazy partitioning

Re: [GENERAL] Triggers inherited?

2007-02-23 Thread Bertram Scharpf
Hi, Am Freitag, 23. Feb 2007, 07:10:06 + schrieb Richard Huxton: > Bertram Scharpf wrote: > >it is very inconvenient for me that triggers aren't inherited: > > Foreign keys too (which are a special type of trigger of course). > > >Is this behaviour to be implemented at any point of time in >

Re: [GENERAL] triggers/constraints?

2005-10-08 Thread Terry Lee Tucker
I believe you have a design problem. It seems to me that you need two tables; one with (id, path) and the other with (parent_id, path). Then you can use an UPDATE trigger on item which checks for a change in path. If it has changed, then you can update all those records in table "item2" where it

[GENERAL] triggers and SELECT

2006-02-01 Thread Sergey Karin
Hi, List! Are there any plans to realize triggers on SELECT in new versions of PG? Sergey Karin

Re: [GENERAL] Triggers & inheritance

2007-09-28 Thread Tom Lane
Scott Ribe <[EMAIL PROTECTED]> writes: > Triggers have never been inherited, right? Not in any version? AFAIR, no. If they had been I kinda doubt we would have removed it. regards, tom lane ---(end of broadcast)--- TIP 4: H

[GENERAL] Triggers and INHERITS

2004-11-29 Thread Joachim Zobel
Hi. I want to use a table CREATE TABLE stats ( upd TIMESTAMP, crt TIMESTAMP DEFAULT NOW() ); with inheritance CREATE sometable ( ) INHERITS stats to automatically maintain update dates. However the obviuos trigger CREATE OR REPLACE FUNCTION stat_upd() RETURNS TRIGGER AS ' BEGIN

Re: [GENERAL] Triggers, again.. ;-)

2005-02-20 Thread Phil Endecott
Greg wrote: > is "DROP TRIGGER" transaction safe?... I mean, could I do: > > BEGIN > DROP TRIGGER category_mv_ut; > ... insert rows > ... update materialized view table > CREATE TRIGGER category_mv_ut AFTER UPDATE ON items > FOR EACH ROW EXECUTE PROCEDURE update_ut(); > COMMIT; > > .. without oth

Re: [GENERAL] Triggers, again.. ;-)

2005-02-21 Thread Net Virtual Mailing Lists
>Greg wrote: > > is "DROP TRIGGER" transaction safe?... I mean, could I do: > > > > BEGIN > > DROP TRIGGER category_mv_ut; > > ... insert rows > > ... update materialized view table > > CREATE TRIGGER category_mv_ut AFTER UPDATE ON items > > FOR EACH ROW EXECUTE PROCEDURE update_ut(); > > COMMIT;

Re: [GENERAL] Triggers, again.. ;-)

2005-02-22 Thread Phil Endecott
Greg asked: > > is "DROP TRIGGER" transaction safe?... I mean, could I do: > > > > BEGIN > > DROP TRIGGER category_mv_ut; > > ... insert rows > > ... update materialized view table > > CREATE TRIGGER category_mv_ut AFTER UPDATE ON items > > FOR EACH ROW EXECUTE PROCEDURE update_ut(); > > COMMIT;

Re: [GENERAL] Triggers, again.. ;-)

2005-02-22 Thread Tom Lane
Phil Endecott <[EMAIL PROTECTED]> writes: > It seems less scary when you think of metadata as just being the content > of more tables, rather than something special. PG does just fine with handling metadata changes transactionally. However, most operations that affect a table's schema at all will

Re: [GENERAL] Triggers, again.. ;-)

2005-02-22 Thread Phil Endecott
Tom Lane wrote: Phil Endecott <[EMAIL PROTECTED]> writes: It seems less scary when you think of metadata as just being the content of more tables, rather than something special. PG does just fine with handling metadata changes transactionally. However, most operations that affect a table's schema

Re: [GENERAL] Triggers, again.. ;-)

2005-02-22 Thread Tom Lane
Phil Endecott <[EMAIL PROTECTED]> writes: > I would understand this if I were doing an "ALTER TABLE", for example. > But does adding or removing a trigger really count as "schema-altering"? [ shrug... ] Hard to say. Probably depends a lot on what the trigger does. I suppose we could at least

Re: [GENERAL] Triggers, again.. ;-)

2005-02-22 Thread mailinglists
> Phil Endecott <[EMAIL PROTECTED]> writes: >> I would understand this if I were doing an "ALTER TABLE", for example. >> But does adding or removing a trigger really count as "schema-altering"? > > [ shrug... ] Hard to say. Probably depends a lot on what the trigger > does. I suppose we could

[GENERAL] Triggers not working

2008-09-21 Thread Dale Harris
Hi, I'm running PostgreSQL 8.3.3 and I'm having trouble with triggers not always working. I have the following tables and functions as documented below. My problem is that if I perform an update on the Entity table and modify the Code field, why doesn't the trigger for the Entity table execut

Re: [GENERAL] Triggers question

2006-03-01 Thread Michael Fuhr
On Wed, Mar 01, 2006 at 02:22:15PM +0100, [EMAIL PROTECTED] wrote: > I want to setup a trigger capable to return more than one record. Your example doesn't show anything related to triggers so I think you mean "function" instead of "trigger." If the function can return more than one row then it's

[GENERAL] Triggers and Transactions

2006-04-21 Thread Chris Coleman
Hi, I have a question about how much of a trigger is in a transaction. I've read the docs and googled around but can't seem to find a concrete answer. I have two triggers that are designed to work together, one is a before trigger and one is an after. If the before trigger succeeds then it will

[GENERAL] Triggers in Postgres

2006-07-31 Thread Jasbinder Bali
Hi,Was wondering if one can write triggers with SQL statements as we have in other RDBMS like SQL Server and oracle. Can these be written in procedural languages only?Please put some insight on what needs to be known before working with triggers in postgres. I've already read the postgres manual in

[GENERAL] triggers and execute...

2009-04-27 Thread Scott Marlowe
OK, I'm hitting a wall here. I've written this trigger for partitioning: create or replace function page_access_insert_trigger () returns trigger as $$ DECLARE part text; q text; BEGIN part = to_char(new."timestamp",'MMDD'); q = 'insert into page_access_'||part

[GENERAL] Triggers and SQL

2009-10-05 Thread Yadisnel Galvez Velazquez
How I cant optain de SQL (if is posible) of any STATEMENT in an AFTER Trigger Function in C? -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

[GENERAL] Triggers and locking

2010-09-21 Thread William Temperley
Dear all, I have a single "source" table that is referenced by six specialization tables, which include: "journal_article" "report" 4 more There is a "citation" column in the source, which is what will be displayed to users. This is generated by a trigger function on each specialization table

Re: [GENERAL] triggers & functions

2000-01-12 Thread Ed Loehr
Sarah Officer wrote: > Can anyone set me straight here? An example of a trigger which > calls a sql procedure would be much appreciated! I'd like the > function to be able to access the rows which are being removed. How about examples of a trigger that calls a *PL/pgSQL* procedure that has acc

Re: [GENERAL] triggers & functions

2000-01-12 Thread Ed Loehr
Oh, and one other thing... The example has a typo. In the function, 'temp' and 'cust' should be the same variable (doesn't matter what it's called). Cheers, Ed Loehr Ed Loehr wrote: > Sarah Officer wrote: > > > Can anyone set me straight here? An example of a trigger which > > calls a sql pr

[GENERAL] triggers in SQL?

2000-09-10 Thread Neil Conway
I want to write a simple trigger in SQL (i.e. use the trigger to execute a simple function written in SQL). I'm having difficulty - CREATE TRIGGER complains if the return type of the procedure is not 'OPAQUE', but CREATE FUNCTION won't allow me to create SQL functions with a return type of OPAQUE.

[GENERAL] Triggers After INSERT

2004-03-17 Thread Stephane Tessier
Hi, I have a problem with triggers in postgresql 7.3.4 and PHP... I have a lot of insert to do from a table x to table y ( average of 1 rows each time). I use a trigger AFTER INSERT but it seems that PHP wait for the result of the trigger to ending the script... Is it possible to avoid waiting

[GENERAL] triggers and plpgsql

2001-08-03 Thread Jakub Ouhrabka
hi, i'm getting strange results when executing the code below. i would expect that li_count in function foo and the select after calling this function should return same values. can anyone explain me why i'm getting these results, please? thanks kuba example (using 7.1.2): CREATE TABLE TC01 ( T

[GENERAL] Triggers and rules

2001-09-28 Thread Mihai Gheorghiu
A table has TRIGGER BEFORE UPDATE, TRIGGER AFTER UPDATE and RULE ON UPDATE. 1. What is the order these three are executed? 2. Are the actions of one of them visible to the following ones, or they all refer strictly to the record before update? E.g.: If the TRIGGER BEFORE UPDATE changes a value in

Re: [GENERAL] triggers and TriggerData

2007-01-21 Thread Alan Hodgson
On Sunday 21 January 2007 15:56, gustavo halperin <[EMAIL PROTECTED]> wrote: > First, thank you for your answers about my problem with the function > 'CREATE TRIGGER', > I have another question about triggers, how can I pass arguments ?? I > read about some struct TriggerData *CurrentTriggerData,

Re: [GENERAL] triggers and TriggerData

2007-01-22 Thread Michael Fuhr
On Sun, Jan 21, 2007 at 09:05:30PM -0800, Alan Hodgson wrote: > On Sunday 21 January 2007 15:56, gustavo halperin <[EMAIL PROTECTED]> wrote: > > I have another question about triggers, how can I pass arguments ?? I > > read about some struct TriggerData *CurrentTriggerData, but I didn't > > found a

Re: [GENERAL] triggers and TriggerData

2007-01-22 Thread Alan Hodgson
On Monday 22 January 2007 07:04, Michael Fuhr <[EMAIL PROTECTED]> wrote: > You can pass literal string arguments to a trigger function. See > the CREATE TRIGGER documentation and, for PL/pgSQL, TG_ARGV and > TG_NARGS. For C see "Writing Trigger Functions in C"; search for > tgnargs and tgargs. >

[GENERAL] triggers vs b-tree

2007-01-25 Thread gustavo halperin
Hello I have a design question: I have a table representing Families, and a table representing Persons. The table Family have a row family_id as primary key. The table Person have a row person_id as primary key and contain also a row family_id. As you can understand, the row family_id in a tabl

[GENERAL] Triggers after a rule

2005-09-28 Thread Wijnand Wiersma
Hi list, I am currently trying to give normal users some read access to some tables in the database. I also need to give update access to one column of one table. I have the table contact, the user should not be able to read or update anything in it, except for his own record. So I created the vi

[GENERAL] Triggers and Audit Trail

2005-12-29 Thread Marcus Couto
Hi all. I'm new with PostgreSQL and this is my first post, so easy on me... :)   I'm thinking of using the native procedural language and triggers to keep an audit trail. For editing changes, we only keep a log of the modified fields and we create a record for each modified value. The audit

Re: [GENERAL] triggers and SELECT

2006-02-01 Thread Tino Wildenhain
Sergey Karin schrieb: Hi, List! Are there any plans to realize triggers on SELECT in new versions of PG? What should they do? You can always use a rule for this... ---(end of broadcast)--- TIP 2: Don't 'kill -9' the postmaster

[GENERAL] triggers/functions across databases

2005-05-25 Thread Eric Jones
We are migrating from Informix to Postgres 7.4.7 and are having a difficult time finding if postgres can insert/update tables across different databases. Namely using functions/triggers when an update/insert is performed on a table it updates/inserts in a table on a different database. Informix

[GENERAL] triggers, transactions and locks

2004-12-06 Thread C G
Dear All, Is there a way to use locks within a trigger? My example below gives the error: ERROR: unexpected error -8 in EXECUTE of query "BEGIN" CONTEXT: PL/pgSQL function "insert_into_t1" line 6 at execute statement Thanks Colin CREATE FUNCTION insert_into_t1() RETURNS trigger AS' DECLA

[GENERAL] Triggers et clefs primaires

2008-08-26 Thread Samuel ROZE
Bonjour, J'ai un trigger (AFTER FOR EACH ROW) sur une table qui à chaque fois qu'il y a un enregistrement sur cette même table, exécute une fonction pgplsql qui éxécute elle-même une fonction PL/sh qui exécute un script PHP. Dans ce script PHP, je créer 10 enregistrements dans une autre tables où

Re: [GENERAL] Triggers not working

2008-09-22 Thread Tom Lane
"Dale Harris" <[EMAIL PROTECTED]> writes: > I'm running PostgreSQL 8.3.3 and I'm having trouble with triggers not always > working. I have the following tables and functions as documented below. My > problem is that if I perform an update on the Entity table and modify the > Code field, why doesn

Re: [GENERAL] Triggers not working

2008-09-22 Thread Dale Harris
t: Re: [GENERAL] Triggers not working "Dale Harris" <[EMAIL PROTECTED]> writes: > I'm running PostgreSQL 8.3.3 and I'm having trouble with triggers not always > working. I have the following tables and functions as documented below. My > problem is that if I p

Re: [GENERAL] Triggers not working

2008-09-22 Thread Tom Lane
"Dale Harris" <[EMAIL PROTECTED]> writes: > The trigger trAccountUpdate got called, but why didn't the trigger > trEntityUpdate get called? Triggers only apply to the exact table they're declared on, not to child tables. It does seem like there might be some use-case for applying a trigger to chi

Re: [GENERAL] Triggers not working

2008-09-22 Thread Dale Harris
:[EMAIL PROTECTED] Sent: Tuesday, 23 September 2008 13:43 To: Dale Harris Cc: pgsql-general@postgresql.org Subject: Re: [GENERAL] Triggers not working "Dale Harris" <[EMAIL PROTECTED]> writes: > The trigger trAccountUpdate got called, but why didn't the trigger >

[GENERAL] triggers problems whit function

2008-10-22 Thread Ma . Cristina Peña C .
I want to use a function in to a trigger This is my CREATE FUNCTION "subradio"(integer) RETURNS integer AS 'select cast(count (claveubica) as integer ) from asradios where ubicacion =0;' LANGUAGE 'sql'; And my ttrigger is CREATE TRIGGER validaradios AFTER DELETE ON subestacion FOR EACH

[GENERAL] Triggers and Multiple Schemas.

2006-03-08 Thread Paul Newman
Hi,  We run with multiple identical schemas in our db. Each schema actually represents a clients db. What we’d like to do is have a common schema where trigger functions and the like are held whilst each trigger defined against the tables is in there own particular schema. This would mean

Re: [GENERAL] Triggers and Transactions

2006-04-21 Thread Terry Lee Tucker
On Thursday 20 April 2006 12:25 pm, "Chris Coleman" <[EMAIL PROTECTED]> thus communicated: --> Hi, --> --> I have a question about how much of a trigger is in a transaction. --> I've read the docs and googled around but can't seem to find a --> concrete answer. --> --> I have two triggers that are

Re: [GENERAL] Triggers in Postgres

2006-07-31 Thread Tino Wildenhain
Jasbinder Bali wrote: > Hi, > Was wondering if one can write triggers with SQL statements as we have > in other RDBMS like SQL Server and oracle. What would such a trigger "in SQL statements" look like? SQL Server has Triggers in Transact-SQL, which is just something like a pl/language. > Can the

Re: [GENERAL] Triggers in Postgres

2006-07-31 Thread Jasbinder Bali
Actually Postgres manual of triggers says that in postgres, you can't write a trigger in conventional sql. You have to write it in a procedural language like C. So wanted some more insight on it. ~Jas  On 7/31/06, Tino Wildenhain <[EMAIL PROTECTED]> wrote: Jasbinder Bali wrote:> Hi,> Was wondering

Re: [GENERAL] Triggers in Postgres

2006-07-31 Thread Richard Huxton
Jasbinder Bali wrote: Actually Postgres manual of triggers says that in postgres, you can't write a trigger in conventional sql. You have to write it in a procedural language like C. So wanted some more insight on it. See chapters 35 - 39 of the manual for details. In particular a discussion

Re: [GENERAL] Triggers in Postgres

2006-08-01 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2006-07-31 11:58:49 -0400: > Actually Postgres manual of triggers says that in postgres, you can't write > a trigger in conventional sql. You have to write it in a procedural language > like C. So wanted some more insight on it. > ~Jas Where does it say so? Do you have a

Re: [GENERAL] Triggers in Postgres

2006-08-01 Thread Jasbinder Bali
http://www.postgresql.org/docs/8.1/interactive/triggers.html   it says something like this:   " It is not currently possible to write a trigger function in the plain SQL function language. "   though lately I saw triggers written in pure sql in postgres   ~jas  On 8/1/06, Roman Neuhauser <[EMAIL PR

Re: [GENERAL] Triggers in Postgres

2006-08-01 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2006-08-01 02:35:48 -0400: > On 8/1/06, Roman Neuhauser <[EMAIL PROTECTED]> wrote: > > > ># [EMAIL PROTECTED] / 2006-07-31 11:58:49 -0400: > >> Actually Postgres manual of triggers says that in postgres, you can't > >write > >> a trigger in conventional sql. You have to write

Re: [GENERAL] Triggers in Postgres

2006-08-01 Thread Chris Mair
> http://www.postgresql.org/docs/8.1/interactive/triggers.html > > it says something like this: > > " It is not currently possible to write a trigger function in the > plain SQL function language. " The whole paragraph says. "It is also possible to write a trigger function in C, although mos

Re: [GENERAL] Triggers in Postgres

2006-08-01 Thread Tom Lane
Chris Mair <[EMAIL PROTECTED]> writes: >> http://www.postgresql.org/docs/8.1/interactive/triggers.html >> " It is not currently possible to write a trigger function in the >> plain SQL function language. " > The whole paragraph says. > "It is also possible to write a trigger function in C, althou

[GENERAL] triggers and FK cascades

2011-03-17 Thread Grzegorz Jaśkiewicz
Considering the following example. Tables A and B. Table A contains some data. Table B reefers to table A using FK with 'on delete cascade'. Table B has a trigger on it, after delete per row Now, is there any way I can tell in the trigger on table B that it has been called from a direct delete on

Re: [GENERAL] triggers and execute...

2009-04-27 Thread Scott Marlowe
On Mon, Apr 27, 2009 at 2:32 PM, Scott Marlowe wrote: > OK, I'm hitting a wall here.  I've written this trigger for partitioning: > > create or replace function page_access_insert_trigger () > returns trigger as $$ > DECLARE >        part text; >        q text; > BEGIN >        part = to_char(new.

Re: [GENERAL] triggers and execute...

2009-04-27 Thread Richard Broersma
On Mon, Apr 27, 2009 at 1:32 PM, Scott Marlowe wrote: > OK, I'm hitting a wall here.  I've written this trigger for partitioning: > > create or replace function page_access_insert_trigger () > returns trigger as $$ > DECLARE >        part text; >        q text; > BEGIN >        part = to_char(new.

Re: [GENERAL] triggers and execute...

2009-04-27 Thread Scott Marlowe
On Mon, Apr 27, 2009 at 3:24 PM, Richard Broersma wrote: > On Mon, Apr 27, 2009 at 1:32 PM, Scott Marlowe > wrote: >> OK, I'm hitting a wall here.  I've written this trigger for partitioning: >> >> create or replace function page_access_insert_trigger () >> returns trigger as $$ >> DECLARE >>  

Re: [GENERAL] triggers and execute...

2009-04-28 Thread Sam Mason
On Mon, Apr 27, 2009 at 03:37:22PM -0600, Scott Marlowe wrote: > On Mon, Apr 27, 2009 at 3:24 PM, Richard Broersma wrote: > > At this point I don't think that there is a way for this function to > > know the correct table type of new.* since page_access_... is still > > only a concatenated string.

Re: [GENERAL] triggers and execute...

2009-04-28 Thread Scott Marlowe
On Mon, Apr 27, 2009 at 3:24 PM, Richard Broersma wrote: > On Mon, Apr 27, 2009 at 1:32 PM, Scott Marlowe > wrote: >> OK, I'm hitting a wall here.  I've written this trigger for partitioning: >> >> create or replace function page_access_insert_trigger () >> returns trigger as $$ >> DECLARE >>  

Re: [GENERAL] triggers and execute...

2009-04-29 Thread Jasen Betts
On 2009-04-29, Scott Marlowe wrote: > On Mon, Apr 27, 2009 at 3:24 PM, Richard Broersma > wrote: >> On Mon, Apr 27, 2009 at 1:32 PM, Scott Marlowe >> wrote: >>> OK, I'm hitting a wall here.  I've written this trigger for partitioning: >>> >>> create or replace function page_access_insert_trigger

Re: [GENERAL] triggers and execute...

2009-04-29 Thread Erik Jones
On Apr 29, 2009, at 4:14 AM, Jasen Betts wrote: On 2009-04-29, Scott Marlowe wrote: On Mon, Apr 27, 2009 at 3:24 PM, Richard Broersma wrote: On Mon, Apr 27, 2009 at 1:32 PM, Scott Marlowe > wrote: OK, I'm hitting a wall here. I've written this trigger for partitioning: create or replace

Re: [GENERAL] triggers and execute...

2009-04-30 Thread Dimitri Fontaine
On Monday 27 April 2009 22:32:22 Scott Marlowe wrote: > OK, I'm hitting a wall here. I've written this trigger for partitioning: > > create or replace function page_access_insert_trigger () > returns trigger as $$ > DECLARE > part text; > q text; > BEGIN > part = to_char(new."tim

Re: [GENERAL] triggers and execute...

2009-04-30 Thread Scott Marlowe
On Tue, Apr 28, 2009 at 11:24 PM, Scott Marlowe wrote: > On Tue, Apr 28, 2009 at 10:46 PM, David Fetter wrote: >> On Tue, Apr 28, 2009 at 08:20:34PM -0600, Scott Marlowe wrote: >>> On Mon, Apr 27, 2009 at 3:24 PM, Richard Broersma >>> wrote: >>> > On Mon, Apr 27, 2009 at 1:32 PM, Scott Marlowe

Re: [GENERAL] triggers and execute...

2009-04-30 Thread David Fetter
On Tue, Apr 28, 2009 at 08:20:34PM -0600, Scott Marlowe wrote: > On Mon, Apr 27, 2009 at 3:24 PM, Richard Broersma > wrote: > > On Mon, Apr 27, 2009 at 1:32 PM, Scott Marlowe > > wrote: > >> OK, I'm hitting a wall here.  I've written this trigger for partitioning: > >> > >> create or replace fun

Re: [GENERAL] triggers and execute...

2009-04-30 Thread Alvaro Herrera
Scott Marlowe escribió: > Oh man, it just gets worse. I really need a simple elegant solution > here, because if I try to build the query by hand null inputs make > life a nightmare. I had built something like this: > > q = 'insert into '||schem||'.page_access_'||part||' values ( >

Re: [GENERAL] triggers and execute...

2009-04-30 Thread Scott Marlowe
On Wed, Apr 29, 2009 at 4:23 AM, Alban Hertroys wrote: > On Apr 29, 2009, at 4:20 AM, Scott Marlowe wrote: > >> Oh man, it just gets worse.  I really need a simple elegant solution >> here, because if I try to build the query by hand null inputs make >> life a nightmare.  I had built something lik

Re: [GENERAL] triggers and execute...

2009-04-30 Thread Richard Broersma
I wonder if it would be easier to perodically replace the entire trigger function with one that inserts to the correct table using CRON+SED rather than dynamically building SQL. This might be a bad idea however. I'm just thinking outside the box. -- Regards, Richard Broersma Jr. Visit the Los

Re: [GENERAL] triggers and execute...

2009-05-01 Thread Scott Marlowe
On Tue, Apr 28, 2009 at 10:46 PM, David Fetter wrote: > On Tue, Apr 28, 2009 at 08:20:34PM -0600, Scott Marlowe wrote: >> On Mon, Apr 27, 2009 at 3:24 PM, Richard Broersma >> wrote: >> > On Mon, Apr 27, 2009 at 1:32 PM, Scott Marlowe >> > wrote: >> >> OK, I'm hitting a wall here.  I've written

Re: [GENERAL] triggers and execute...

2009-05-01 Thread Alban Hertroys
On Apr 29, 2009, at 4:20 AM, Scott Marlowe wrote: Oh man, it just gets worse. I really need a simple elegant solution here, because if I try to build the query by hand null inputs make life a nightmare. I had built something like this: q = 'insert into '||schem||'.page_access_'||part||' value

Fwd: [GENERAL] triggers and execute...

2009-05-01 Thread Dimitri Fontaine
Hi, it seems it didn't make it the first time. Début du message réexpédié : De : Dimitri Fontaine Date : 30 avril 2009 12:03:10 HAEC À : pgsql-general@postgresql.org Objet : Rép : [GENERAL] triggers and execute... On Monday 27 April 2009 22:32:22 Scott Marlowe wrote: OK, I'm hitt

Re: [GENERAL] Triggers and locking

2010-09-21 Thread Alban Hertroys
On 21 Sep 2010, at 16:13, William Temperley wrote: > Dear all, > > I have a single "source" table that is referenced by six > specialization tables, which include: > "journal_article" > "report" > 4 more > > e.g.: > """ > update source set citation = get_report_citation( >(select source

Re: [GENERAL] Triggers and locking

2010-09-21 Thread William Temperley
On 21 September 2010 18:39, Alban Hertroys wrote: > On 21 Sep 2010, at 16:13, William Temperley wrote: > >> Dear all, >> >> I have a single "source" table that is referenced by six >> specialization tables, which include: >> "journal_article" >> "report" >> 4 more >> >> e.g.: >> """ >> update

Re: [GENERAL] Triggers with arguments

2000-07-12 Thread Richard Harvey Chapman
If I understand correctly, you have something like this: CREATE TABLE rec_* ( num integer primary key; other ... ); CREATE TABLE notes ( name CHAR(20), numINTEGER, note VARCHAR(200), PRIMARY KEY(name, num) ); So, you have many different tables like rec_*

Re: [GENERAL] Triggers with arguments

2000-07-12 Thread Scott Holmes
What I'm after are triggers on delete fro several tables calling the same procedure. I am not at liberty to change the schema of the database as I need to accomodate what is actually an ancient system - that goes back before the days of blobs and large text fields. In my example, deleting a r

Re: [GENERAL] Triggers with arguments

2000-07-12 Thread Tom Lane
Scott Holmes <[EMAIL PROTECTED]> writes: > CREATE FUNCTION del_stxnoted () RETURNS opaque AS ' > DECLARE > fname alias for $1; > rkey alias for $2; > BEGIN > delete from stxnoted where filename = fname >and record_key = rkey; > END;' > LANGUAGE 'plpgsql'; > create trigg

Re: [GENERAL] Triggers with arguments

2000-07-12 Thread Robert B. Easter
On Wed, 12 Jul 2000, Scott Holmes wrote: > I'm afraid I just don't see how this is done without being able to pass > arguments to the procedure or actually running an additional SQL statement > within the trigger: > > I have a "notes" table that is potentially linked to records in many othe

Re: [GENERAL] triggers in SQL?

2000-09-10 Thread Neil Conway
On Sun, Sep 10, 2000 at 02:36:39PM -0400, Neil Conway wrote: > I want to write a simple trigger in SQL (i.e. use the trigger to execute > a simple function written in SQL). I'm having difficulty - CREATE TRIGGER > complains if the return type of the procedure is not 'OPAQUE', but CREATE > FUNCTION

Re: [GENERAL] Triggers After INSERT

2004-03-17 Thread Gregory Wood
Stephane Tessier wrote: Hi, I have a problem with triggers in postgresql 7.3.4 and PHP... I have a lot of insert to do from a table x to table y ( average of 1 rows each time). I use a trigger AFTER INSERT but it seems that PHP wait for the result of the trigger to ending the script... Is it p

Re: [GENERAL] triggers vs b-tree

2007-01-26 Thread Joris Dobbelsteen
I believe you should design it in a slightly different way: >-Original Message- >From: [EMAIL PROTECTED] >[mailto:[EMAIL PROTECTED] On Behalf Of >gustavo halperin >Sent: donderdag 25 januari 2007 21:34 >To: pgsql-general@postgresql.org >Subject: [GENERAL] triggers

Re: [GENERAL] triggers vs b-tree

2007-01-26 Thread Tomas Vondra
> Hello I have a design question: > > I have a table representing Families, and a table representing Persons. > The table Family have a row family_id as primary key. > The table Person have a row person_id as primary key and contain also a > row family_id. > As you can understand, the row family_

Re: [GENERAL] Triggers after a rule

2005-09-28 Thread Richard Huxton
Wijnand Wiersma wrote: I have the table contact, the user should not be able to read or update anything in it, except for his own record. So I created the view v_my_account. When the user selects * from it he only sees his own record. That works great. I also made a rule: CREATE RULE update_v_my_

  1   2   >