Module Inspection problem with prepare

  • SK3

    SK3 - 2009-11-06

    My question is :
    I tried to connect with database by dbi,
            I can see connect automatically by Inspection.
            but I can't see prepare / execute method by inspection.
           When I am tring to add prepare method by inspection , I can see    parse_dsn(), parse_trace_flag() and parse_trace_flags()
         but Ican't see prepare method
    what is the reason
    The test program is working fine, any advise This is my code:


    use DBI;
    use DBD::Pg;
    use strict;

    print "Content-type: text/html \n\n";

    my $driver ="Pg";
    my $database ="ledgersmb";
    my $dsn = "DBI:$driver:database=$database";

    #my $dbconnect = "dbi:Pg:testDB:localhost:3306";

    my $user ="testuser";
    my $pw   ="testpw";

    my $dbh = DBI->connect($dsn,$user,$pw);

    my $query ="select * from users";

    my $queryHandler =  $dbh->prepare($query) or die "error in prepare" ;

    $queryHandler->execute() or die ("error in execurte");

    Thank you so much for your patient and your support

  • Jan Ploski

    Jan Ploski - 2009-11-06

    If you look at the source code of, you will find there is no 'sub prepare' in there. It is added dynamically at run time, thus not available to static inspection.

  • SK3

    SK3 - 2009-11-06

    Is there any solution for that, or Is there dynamic inspection.
    Thanks a lot for your support and your time

  • Jan Ploski

    Jan Ploski - 2009-11-06

    There's no solution and no dynamic inspection. Dynamic means that the code to be inspected would have to be executed first, but there's no way to tell in general what to execute and what not and which preconditions have to be true in order for the execution to be useful.

    If you need reliable inspection in an IDE, you should use a strongly typed language (such as Java), and even so you'd find cases where it wouldn't work.

    If you badly need it for a particular case in Perl/EPIC, then you may want to write a wrapper module which has subroutines that don't pop into existence at runtime (such a wrapper module would incur some performance overhead over "pure" DBI).

  • SK3

    SK3 - 2009-11-09

    Thank you so much for your replay and explanation Jploski, I understand now the situation. and Thank you Matisse for your Module, The idea of module is very nice and useful .


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks