MS SQL triggers and ruby

Discussion in 'Ruby' started by Guillaume Marcais, Apr 22, 2004.

  1. Is there a way for a trigger in MS SQL 2000 to fire some ruby code? I
    would like to act upon the insertion of some data in the database.

    Guillaume.
    Guillaume Marcais, Apr 22, 2004
    #1
    1. Advertising

  2. "Guillaume Marcais" <> wrote in message
    > Is there a way for a trigger in MS SQL 2000 to fire some ruby code? I
    > would like to act upon the insertion of some data in the database.


    Sure ! First make sure that you do not have any important table named
    RUBY_TEST in the PUBS database and run this in Query Analyzer :
    -----------------------------------------------------------------------
    USE PUBS

    IF OBJECT_ID('RUBY_TEST','U') is not NULL
    DROP TABLE RUBY_TEST

    CREATE TABLE RUBY_TEST(A INT)

    GO

    IF EXISTS (SELECT name
    FROM sysobjects
    WHERE name = N'trig_test'
    AND type = 'TR')
    DROP TRIGGER trig_test
    GO

    CREATE TRIGGER trig_test
    ON RUBY_TEST
    FOR DELETE, INSERT, UPDATE
    AS
    BEGIN
    EXEC master..xp_cmdshell 'c:\ruby\bin\ruby -ve "puts %Q{Hello World}"'
    END

    GO

    INSERT INTO RUBY_TEST VALUES(20)
    ------------------------------------------------
    Shashank Date, Apr 22, 2004
    #2
    1. Advertising

  3. Thanx

    Le 21 avr. 04, à 19:59, Shashank Date a écrit :

    >
    > "Guillaume Marcais" <> wrote in message
    >> Is there a way for a trigger in MS SQL 2000 to fire some ruby code? I
    >> would like to act upon the insertion of some data in the database.

    >
    > Sure ! First make sure that you do not have any important table named
    > RUBY_TEST in the PUBS database and run this in Query Analyzer :
    > -----------------------------------------------------------------------
    > USE PUBS
    >
    > IF OBJECT_ID('RUBY_TEST','U') is not NULL
    > DROP TABLE RUBY_TEST
    >
    > CREATE TABLE RUBY_TEST(A INT)
    >
    > GO
    >
    > IF EXISTS (SELECT name
    > FROM sysobjects
    > WHERE name = N'trig_test'
    > AND type = 'TR')
    > DROP TRIGGER trig_test
    > GO
    >
    > CREATE TRIGGER trig_test
    > ON RUBY_TEST
    > FOR DELETE, INSERT, UPDATE
    > AS
    > BEGIN
    > EXEC master..xp_cmdshell 'c:\ruby\bin\ruby -ve "puts %Q{Hello World}"'
    > END
    >
    > GO
    >
    > INSERT INTO RUBY_TEST VALUES(20)
    > ------------------------------------------------
    >
    >
    >
    >
    Guillaume Marcais, Apr 22, 2004
    #3
  4. My object-relational mapping library Lafcadio also has triggers in it.
    You can check it out at http://lafcadio.rubyforge.org/ . You can write
    both pre- and post-commit triggers in Ruby code, and you can even
    write automated tests against those triggers if that's your sort of
    thing.

    Lafcadio was written first for MySQL but I know somebody who's managed
    to make use of it with MS SQL Server.

    Francis

    Guillaume Marcais <> wrote in message news:<>...
    > Thanx
    >
    > Le 21 avr. 04, à 19:59, Shashank Date a écrit :
    >
    > >
    > > "Guillaume Marcais" <> wrote in message
    > >> Is there a way for a trigger in MS SQL 2000 to fire some ruby code? I
    > >> would like to act upon the insertion of some data in the database.

    > >
    > > Sure ! First make sure that you do not have any important table named
    > > RUBY_TEST in the PUBS database and run this in Query Analyzer :
    > > -----------------------------------------------------------------------
    > > USE PUBS
    > >
    > > IF OBJECT_ID('RUBY_TEST','U') is not NULL
    > > DROP TABLE RUBY_TEST
    > >
    > > CREATE TABLE RUBY_TEST(A INT)
    > >
    > > GO
    > >
    > > IF EXISTS (SELECT name
    > > FROM sysobjects
    > > WHERE name = N'trig_test'
    > > AND type = 'TR')
    > > DROP TRIGGER trig_test
    > > GO
    > >
    > > CREATE TRIGGER trig_test
    > > ON RUBY_TEST
    > > FOR DELETE, INSERT, UPDATE
    > > AS
    > > BEGIN
    > > EXEC master..xp_cmdshell 'c:\ruby\bin\ruby -ve "puts %Q{Hello World}"'
    > > END
    > >
    > > GO
    > >
    > > INSERT INTO RUBY_TEST VALUES(20)
    > > ------------------------------------------------
    > >
    > >
    > >
    > >
    Francis Hwang, Apr 23, 2004
    #4
  5. Hello Francis,

    Friday, April 23, 2004, 9:14:06 PM, you wrote:

    FH> My object-relational mapping library Lafcadio also has triggers in it.
    FH> You can check it out at http://lafcadio.rubyforge.org/ . You can write
    FH> both pre- and post-commit triggers in Ruby code, and you can even
    FH> write automated tests against those triggers if that's your sort of
    FH> thing.

    FH> Lafcadio was written first for MySQL but I know somebody who's managed
    FH> to make use of it with MS SQL Server.

    And did he send you the patches ?


    --
    Best regards,
    Lothar mailto:
    Lothar Scholz, Apr 23, 2004
    #5
  6. Lothar Scholz <> wrote in message news:<>...
    > Hello Francis,
    >
    > Friday, April 23, 2004, 9:14:06 PM, you wrote:
    >
    > FH> My object-relational mapping library Lafcadio also has triggers in it.
    > FH> You can check it out at http://lafcadio.rubyforge.org/ . You can write
    > FH> both pre- and post-commit triggers in Ruby code, and you can even
    > FH> write automated tests against those triggers if that's your sort of
    > FH> thing.
    >
    > FH> Lafcadio was written first for MySQL but I know somebody who's managed
    > FH> to make use of it with MS SQL Server.
    >
    > And did he send you the patches ?


    Well, it's Kaspar, and he's sent me patches for plenty of other
    things, but not for MS SQL. Which leads me to believe that at the
    level of SQL that Lafcadio uses there are no patches necessary.

    FWIW, I'm very interested in supporting any DB, but I'm not certain
    exactly how to do it with MS SQL since I don't have regular access to
    a Windows box that I could use to ensure things were working. (My
    computing life is solidly OS X and Linux these days.) I wonder how
    other project maintainers handle this sort of thing.

    F.
    Francis Hwang, Apr 24, 2004
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Itamar Lev
    Replies:
    0
    Views:
    1,840
    Itamar Lev
    Aug 26, 2003
  2. =?Utf-8?B?QWxleA==?=

    Ajax - ascx and updatepanel triggers

    =?Utf-8?B?QWxleA==?=, Apr 26, 2007, in forum: ASP .Net
    Replies:
    0
    Views:
    798
    =?Utf-8?B?QWxleA==?=
    Apr 26, 2007
  3. Guest
    Replies:
    3
    Views:
    760
    Patrice
    Sep 27, 2008
  4. Andy B
    Replies:
    1
    Views:
    817
    Benjamin Crisp
    Jan 26, 2009
  5. Keith

    SQL Triggers for Auditing

    Keith, Jun 24, 2004, in forum: ASP General
    Replies:
    3
    Views:
    268
    Keith
    Jun 24, 2004
Loading...

Share This Page