Thread: trigger proceedures in sql

trigger proceedures in sql

From
"adivi"
Date:
hi,
 
      can trigger proceedures ( procedures to be executed from within a trigger )
        not be written in sql.
 
      i was looking for examples and can find proceedures in 'c' only.
 
regards
-adivi

Re: trigger proceedures in sql

From
"David Witham"
Date:
Hi Adivi,
 
You can use PL/PgSQL functions with triggers. See chapter 19 of the programmers reference:
 
 
regards,
David
-----Original Message-----
From: adivi [mailto:adivi@maximizelearning.com]
Sent: Thursday, 10 July 2003 15:40
To: pgsql-sql@postgresql.org
Subject: [SQL] trigger proceedures in sql

hi,
 
      can trigger proceedures ( procedures to be executed from within a trigger )
        not be written in sql.
 
      i was looking for examples and can find proceedures in 'c' only.
 
regards
-adivi

Re: trigger proceedures in sql

From
Richard Huxton
Date:
On Thursday 10 Jul 2003 6:40 am, adivi wrote:
> hi,
>
>       can trigger proceedures ( procedures to be executed from within a
> trigger ) not be written in sql.
>
>       i was looking for examples and can find proceedures in 'c' only.

AFAIK you can't use "sql", but you can use "plpgsql". There is an example of a
trigger function in the docs (chapter "Procedural Languages"). Also check out
http://techdocs.postgresql.org/ - there are examples in some of the docs
there.

--  Richard Huxton


Re: trigger proceedures in sql

From
"scott.marlowe"
Date:
On Thu, 10 Jul 2003, adivi wrote:

> hi,
> 
>       can trigger proceedures ( procedures to be executed from within a trigger )
>         not be written in sql.
> 
>       i was looking for examples and can find proceedures in 'c' only.

they can be written in pl/pgsql for sure, as I've written a few. :-)

Here's the section in the developer docs on triggers in plpgsql:

http://developer.postgresql.org/docs/postgres/plpgsql-trigger.html





Re: trigger proceedures in sql

From
Stephan Szabo
Date:
On Thu, 10 Jul 2003, adivi wrote:

>       can trigger proceedures ( procedures to be executed from within a trigger )
>         not be written in sql.

AFAICT, no, sql functions cannot return opaque/trigger.  However you can
write trigger functions in most/all of the pl languages (plpgsql, pltcl,
etc...)  I think the trigger examples for plpgsql are in plpgsql's
documentation.



Re: trigger proceedures in sql

From
Jonathan Gardner
Date:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Wednesday 09 July 2003 22:40, adivi wrote:
> hi,
>
>       can trigger proceedures ( procedures to be executed from within a
> trigger ) not be written in sql.
>
>       i was looking for examples and can find proceedures in 'c' only.
>

You may write them in PL/pgSQL, PL/Python, etc... Each language has examples
on how to set up triggers. So you will need to read about PL/pgSQL and
PL/Python to figure out how to write triggers in those languages.

I don't think you can write triggers in pure SQL.

- --
Jonathan Gardner <jgardner@jonathangardner.net>
(was jgardn@alumni.washington.edu)
Live Free, Use Linux!
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE/Dbt3WgwF3QvpWNwRAiRvAJ4ojWIGRGeuTQHY5ckOnepy0LBu9gCgoTl1
XaM7clW3uelccH/w0iaAA/k=
=R7do
-----END PGP SIGNATURE-----


Re: trigger proceedures in sql

From
Rajesh Kumar Mallah
Date:

Yes of course!
contrib/dbmirror does execute a procedure written in 'C'
called recordchange()  ON update , insert , delete.
If you need help in getting its source lemme know.

regds
Mallah.

On Thursday 10 Jul 2003 11:10 am, adivi wrote:
> hi,
>
>       can trigger proceedures ( procedures to be executed from within a
> trigger ) not be written in sql.
>
>       i was looking for examples and can find proceedures in 'c' only.
>
> regards
> -adivi



Re: trigger proceedures in sql

From
Jan Wieck
Date:
Rajesh Kumar Mallah wrote:
> 
> Yes of course!
> contrib/dbmirror does execute a procedure written in 'C'
> called recordchange()  ON update , insert , delete.
> If you need help in getting its source lemme know.
> 
> regds
> Mallah.
> 
> On Thursday 10 Jul 2003 11:10 am, adivi wrote:
>> hi,
>>
>>       can trigger proceedures ( procedures to be executed from within a
>> trigger ) not be written in sql.
>>
>>       i was looking for examples and can find proceedures in 'c' only.

Trigger procedures can also be written in many procedural languages like 
PL/Perl, PL/Tcl and PL/pgSQL (what you should be looking at closer). 
Examples for PL/pgSQL can be found in the regression test.


Jan

-- 
#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me.                                  #
#================================================== JanWieck@Yahoo.com #