Greetings - all perl monks from past and present. Having a hell of a time trying to set a MySQL trigger using mysql-pp. I have a data base named ec_user. inside of that I have multiple tables. ec_user.login AND ec_user.user. BOTH contain the field: type. Trying to create a MySQL Trigger that when ec_user.login.type is updated MySQL will auto update ec_user.user.type. Here is the code I have so far:
    $sql = "CREATE TRIGGER updt_type BEFORE UPDATE ON ec_user.login.type
        BEGIN
	    INSERT INTO ec_user.user.type
	    SET ec_user.user.type = NEW.ec_user.login.type,
	    tec_id = OLD.tec_id;
	END;
    ";
    $sth = $dbh->prepare($sql);
    $sth ->execute() or die "Connection Error: $DBI::errstr\n";
    $sth->finish();
    $dbh->disconnect();
I didn't include the MySQL-pp connection $dbh - I will, but I don't think its relevant....... When I run this is what I the error I get: (with strict enabled)
DBD::mysqlPP::st execute failed: #42000You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.type
                BEGIN
                        INSERT INTO ec_user.user.type
                        SET ec_user.user.type = '',
                ' at line 1 at tables/user.pm line 106.
Connection Error: #42000You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.type
                BEGIN
                        INSERT INTO ec_user.user.type
                        SET ec_user.user.type = '',
                ' at line 1
Compilation failed in require at C:\inetpub\wwwroot\TEC\++ Database ++\db\db.pl line 250.
Thanks for the help in advanced!

In reply to MySQL-pp, Perl and MySQL Triggers by skosterow

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.