in reply to RFC: DBIx::Declare - generate code to call stored procs/SQL statements

That's very nice, it's exactly the way I usually do it, though I usually wrote an ad hoc module for every program... I'm happy to see your laziness and hubris have beaten me :)
  • Comment on Re: RFC: DBIx::Declare - generate code to call stored procs/SQL statements

Replies are listed 'Best First'.
Re^2: RFC: DBIx::Declare - generate code to call stored procs/SQL statements
by Jenda (Abbot) on May 21, 2009 at 23:09 UTC

    Thanks :-) Do you have any suggestions regarding what you'd like the module to support? As I wrote I plan to add support for stored procedures in mysql, but I have neither Oracle nor PostgreSQL and do not need to support them myself. Another thing I consider adding is the ability to write the generated methods to the disk (or maybe some other cache as well?) and load them from there by the next instance of the script, though I'm not sure how big improvement would that be. And possibly some way to have all the methods generated right away instead of on the first use and optionally written somewhere. That way you might be able to generate all the code and later use the generated code directly instead of this module.

    Even as it is you can use the module to generate the method and copy&paste it somewhere. If you set the environment variable DBIx_Declare_Debug (before the first use DBIx::Declare ... in your script) you get some debug info and the generated code or if you set the $db->{_show_generated_code} to a true value, you get just the generated code on STDOUT.

    Jenda
    Enoch was right!
    Enjoy the last years of Rome.

      Well, I don't actually care about Oracle, but postgres is a must-have for me :) I'll have a look at your code, but right now I'm upgrading my machine and still haven't reinstalled postgresql :)

        Hopefully you'll just need to implement a PostgreSQL specific _InferSQL. It's supposed to find the parameters of the stored procedure and set the SQL statement, the args array and the out_args hash (each key should point to an array containing the max size, the SQL type (DBI::SQL_INTEGER, ...) and the string containing the type ('varchar(100)',...). Contact me on jenda@krynicky.cz please once you have the necessary spare time :-)

        Jenda
        Enoch was right!
        Enjoy the last years of Rome.