Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks

I apologize for my ignorance but I am not a seasoned perl programmer. Is it possible to use perl dbi to create database variables in mysql and retrieve the value of this variable. I would like to use a database variable within a trigger and I would like to access this value from the perl script. I could not find anything on this in the dbi docs

Kind regards

Replies are listed 'Best First'.
Re: using dbi to set database variables
by ikegami (Patriarch) on May 17, 2011 at 22:17 UTC
    You can execute arbitrary SQL statements with execute (or do if you don't need to fetch any results), so I don't understand how this is a DBI issue.
Re: using dbi to set database variables
by wind (Priest) on May 17, 2011 at 22:15 UTC

    Why not just add this "variable" as a value in a table record? Even a table that is just 2 columns, a primary key and a value.

Re: using dbi to set database variables
by Anonymous Monk on May 17, 2011 at 22:16 UTC
    I should have added more detail to the question. Imagine this trigger
    CREATE TRIGGER bar AFTER INSERT ON foo FOR EACH ROW BEGIN DECLARE x INT; SET x = NEW.i; SET @a = x; -- set user variable outside trigger END//
    I would need to be able to perform the following in perl
    SET @a = 0; SELECT @a;
    Can i perform a select @a using the standard dbi methods? What would i use to issue the SET command. Could i just use a sth execute call? I will look at this now. By asking the question I have helped myself answer it i think