pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
how to execute a C program via trigger ?
5+ messages / 4 participants
[nested] [flat]

* how to execute a C program via trigger ?
@ 2000-12-04 08:47  S.F. Lee <sflee_tw@yahoo.com>
  0 siblings, 2 replies; 5+ messages in thread

From: S.F. Lee @ 2000-12-04 08:47 UTC (permalink / raw)
  To: pgsql-sql

Hi,
   
   I am using Red Hat 6.1 + PostgreSQL 7.0.3. All of
my
applications are developed by C and ECPG.  I would
like to know how to execute a C program by Trigger,for
example:


   1. I have a program my_c_program.c shuch as:

#include <stdio.h>
main()
{
   printf("Hello World !\n");
}

   2. I create a table foo by following command

CREATE TABLE foo
	(
	x      int4
	);

   3. create a trigger  foo_trig :

create trigger foo_trig after update
    on foo for each row execute procedure sql_c();
   
   4. I don't know how to design sql_c(), can anyone
      give a small plpsql program that can execute
      my_c_program?  

   regards,    S.F. Lee


__________________________________________________
Do You Yahoo!?
Yahoo! Shopping - Thousands of Stores. Millions of Products.
http://shopping.yahoo.com/



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: how to execute a C program via trigger ?
@ 2000-12-04 17:57  clayton cottingham <clayton@marketingchallenge.com>
  parent: S.F. Lee <sflee_tw@yahoo.com>
  1 sibling, 0 replies; 5+ messages in thread

From: clayton cottingham @ 2000-12-04 17:57 UTC (permalink / raw)
  To: S.F. Lee <sflee_tw@yahoo.com>; +Cc: pgsql-sql

take a look at the contrib sections fti or fulltext index example

it takes you through it all



"S.F. Lee" wrote:
> 
> Hi,
> 
>    I am using Red Hat 6.1 + PostgreSQL 7.0.3. All of
> my
> applications are developed by C and ECPG.  I would
> like to know how to execute a C program by Trigger,for
> example:
> 
>    1. I have a program my_c_program.c shuch as:
> 
> #include <stdio.h>
> main()
> {
>    printf("Hello World !\n");
> }
> 
>    2. I create a table foo by following command
> 
> CREATE TABLE foo
>         (
>         x      int4
>         );
> 
>    3. create a trigger  foo_trig :
> 
> create trigger foo_trig after update
>     on foo for each row execute procedure sql_c();
> 
>    4. I don't know how to design sql_c(), can anyone
>       give a small plpsql program that can execute
>       my_c_program?
> 
>    regards,    S.F. Lee
> 
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Shopping - Thousands of Stores. Millions of Products.
> http://shopping.yahoo.com/



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: how to execute a C program via trigger ?
@ 2000-12-05 02:20  S.F. Lee <sflee_tw@yahoo.com>
  0 siblings, 1 reply; 5+ messages in thread

From: S.F. Lee @ 2000-12-05 02:20 UTC (permalink / raw)
  To: clayton cottingham <clayton@marketingchallenge.com>; +Cc: pgsql-sql

Thank for your hint, but I have some questions :

  1. Do I have to compile the C program into a shared
object (*.so)? 
  2. Do I have to use SPI (SPI is too complicate to
me)? 

  My request is very simple. I have a program
(my_c_program) 
  that I can execute it under shell by typing
(my_c_program).
  Basically my_c_program is not a function.

  I want to fire a trigger after I update the field
(x) in table foo, and the trigger can run the
my_c_program. Is there an easy way to execute a
PROCESS
via trigger?

   regards,    S.F. Lee

--- clayton cottingham
<clayton@marketingchallenge.com> wrote:
> take a look at the contrib sections fti or fulltext
> index example
> 
> it takes you through it all
> 
> 
> 
> "S.F. Lee" wrote:
> > 
> > Hi,
> > 
> >    I am using Red Hat 6.1 + PostgreSQL 7.0.3. All
> of
> > my
> > applications are developed by C and ECPG.  I would
> > like to know how to execute a C program by
> Trigger,for
> > example:
> > 
> >    1. I have a program my_c_program.c shuch as:
> > 
> > #include <stdio.h>
> > main()
> > {
> >    printf("Hello World !\n");
> > }
> > 
> >    2. I create a table foo by following command
> > 
> > CREATE TABLE foo
> >         (
> >         x      int4
> >         );
> > 
> >    3. create a trigger  foo_trig :
> > 
> > create trigger foo_trig after update
> >     on foo for each row execute procedure sql_c();
> > 
> >    4. I don't know how to design sql_c(), can
> anyone
> >       give a small plpsql program that can execute
> >       my_c_program?
> > 
> >    regards,    S.F. Lee
> > 
> > __________________________________________________
> > Do You Yahoo!?
> > Yahoo! Shopping - Thousands of Stores. Millions of
> Products.
> > http://shopping.yahoo.com/


__________________________________________________
Do You Yahoo!?
Yahoo! Shopping - Thousands of Stores. Millions of Products.
http://shopping.yahoo.com/



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: how to execute a C program via trigger ?
@ 2000-12-05 09:58  Clayton Cottingham <clayton@marketingchallenge.com>
  parent: S.F. Lee <sflee_tw@yahoo.com>
  0 siblings, 0 replies; 5+ messages in thread

From: Clayton Cottingham @ 2000-12-05 09:58 UTC (permalink / raw)
  To: S.F. Lee <sflee_tw@yahoo.com>; +Cc: pgsql-sql


On Mon, 4 Dec 2000 18:20:29 -0800 (PST), S.F. Lee said:

> Thank for your hint, but I have some questions :
>  
>    1. Do I have to compile the C program into a shared
>  object (*.so)? 

yes

>    2. Do I have to use SPI (SPI is too complicate to
>  me)? 
>  
>    My request is very simple. I have a program
>  (my_c_program) 
>    that I can execute it under shell by typing
>  (my_c_program).
>    Basically my_c_program is not a function.
>  


im not sure anyone?


>    I want to fire a trigger after I update the field
>  (x) in table foo, and the trigger can run the
>  my_c_program. Is there an easy way to execute a
>  PROCESS
>  via trigger?
>  
>     regards,    S.F. Lee
>  


id say dont use C!! use pl/sql 

but if your trying to learn the prog of c functions
youll have to get help elsewhere unfortunatley

im not even newbie status on c!



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: how to execute a C program via trigger ?
@ 2000-12-07 23:01  Jie Liang <jliang@ipinc.com>
  parent: S.F. Lee <sflee_tw@yahoo.com>
  1 sibling, 0 replies; 5+ messages in thread

From: Jie Liang @ 2000-12-07 23:01 UTC (permalink / raw)
  To: ; +Cc: pgsql-sql

Hi,

Is any other SQL implicit cursor attribute in PL/plsql ??

when you say (in pl/plsql):

select field into v_1 from atable where whatever;

special variable FOUND can be used to tell return is null or not.

this functions like SQL%FOUND or SQL%NOTFOUND in Oracle,

however, when I do some DML(insert,delete,update), is there any other

special variable can tell me howmany success. Like SQL%ROWCOUNT in Orcale??

And if there is an error such as : cannot insert since duplicate key on an

unique index, is it possible to catch it??

Thanks.

--
Jie LIANG

Internet Products Inc.

10350 Science Center Drive
Suite 100, San Diego, CA 92121
Office:(858)320-4873

jliang@ipinc.com
www.ipinc.com






^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2000-12-07 23:01 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2000-12-04 08:47 how to execute a C program via trigger ? S.F. Lee <sflee_tw@yahoo.com>
2000-12-04 17:57 ` clayton cottingham <clayton@marketingchallenge.com>
2000-12-07 23:01 ` Jie Liang <jliang@ipinc.com>
2000-12-05 02:20 Re: how to execute a C program via trigger ? S.F. Lee <sflee_tw@yahoo.com>
2000-12-05 09:58 ` Clayton Cottingham <clayton@marketingchallenge.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox