Professional Web Applications Themes

Question regarding databases.. - PERL Modules

Hello, I wasn't sure if this should go in this usenet or in something like Perl.DBI.etc, so I apologize if this is in the wrong place. Pretty simple question. I would like to create a Perl shell script that actively monitors a table in a database. Let's exemplify this before i go any further... Let's say I have a table with some data: ID Name Info is_processed where ID, Name and Info are just arbitrary bits of data, not important to this specifically. I'd also like an "is_processed" field that'll be either 1 or 0. The idea behind this backend ...

  1. #1

    Default Question regarding databases..

    Hello,

    I wasn't sure if this should go in this usenet or in something like
    Perl.DBI.etc, so I apologize if this is in the wrong place.

    Pretty simple question. I would like to create a Perl shell script
    that actively monitors a table in a database. Let's exemplify this
    before i go any further...

    Let's say I have a table with some data:

    ID Name Info is_processed

    where ID, Name and Info are just arbitrary bits of data, not important
    to this specifically. I'd also like an "is_processed" field that'll be
    either 1 or 0. The idea behind this backend shell script is so that
    some frontend application can add data to the database quickly and get
    a quick response for the user on the website. The backend script will
    be actively monitoring the database, and whenever it sees something
    whose "is_processed" value is 0, it says "hey, let me process that,"
    and if the action is successful changes the value to 1 and never has to
    touch that record again. The "is_processed" value might be zero for two
    reasons: 1) That record was just added by the frontend script (webpage)
    and hasn't yet been touched by the backend script, or 2) The backend
    script wasn't able to process that recordset on a previous attempt.

    That's the idea... the only problem is, I don't know how to make this
    database connection "live," ie I don't know how to write a program that
    just sits there running, looking for changes in a database, without
    ever terminating (unless by command).

    Any ideas? Your help is more than greatly appreciated.

    Thanks,
    Burak

    burak@lysurge.net Guest

  2. #2

    Default Re: Question regarding databases..

    In article <1132335666.112663.56030g14g2000cwa.googlegroups. com>,
    <buraklysurge.net> wrote:
    > Hello,
    >
    > I wasn't sure if this should go in this usenet or in something like
    > Perl.DBI.etc, so I apologize if this is in the wrong place.
    >
    > Pretty simple question. I would like to create a Perl shell script
    > that actively monitors a table in a database. Let's exemplify this
    > before i go any further...
    [further description snipped]
    >
    > That's the idea... the only problem is, I don't know how to make this
    > database connection "live," ie I don't know how to write a program that
    > just sits there running, looking for changes in a database, without
    > ever terminating (unless by command).
    >
    > Any ideas? Your help is more than greatly appreciated.
    You can use the sleep statement in your Perl program to have your
    program periodically wake up and check the database table to see if
    anything has changed. You can make the period whatever you like, in
    multiples of 1 second. However, that is not the most efficient
    solution, because your program might be doing a lot of checking with
    nothing to do.

    A better solution involves having some mechanism to activate your
    program when there is something to do. The simplest way is to just
    execute it -- however this involves some program activation and
    database connection delays. A better solution is for your program to
    start execution, connect to the database, and then wait for some event
    to occur. There are several such mechanisms, depending upon your
    platform. These include, for Unix at least, signals, shared memory,
    I/O, semaphores, mutexes, etc. See 'perldoc perlipc' for more
    information.

    Posted Via Usenet.com Premium Usenet Newsgroup Services
    ----------------------------------------------------------
    ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
    ----------------------------------------------------------
    [url]http://www.usenet.com[/url]
    Jim Gibson Guest

Similar Threads

  1. databases
    By max in forum ASP.NET Web Services
    Replies: 8
    Last Post: October 21st, 05:22 PM
  2. ASP & Databases
    By McKirahan in forum ASP Database
    Replies: 7
    Last Post: April 11th, 08:31 AM
  3. [PHP] Databases
    By Duncan Hill in forum PHP Development
    Replies: 1
    Last Post: September 25th, 09:48 AM
  4. PHP and databases
    By Craig in forum PHP Development
    Replies: 5
    Last Post: August 21st, 07:59 AM
  5. Federated Databases, joins across databases etc
    By Benjamin Stewart in forum IBM DB2
    Replies: 2
    Last Post: August 1st, 03:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139