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:
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
If you look at the source code of DBI.pm, you will find there is no 'sub prepare' in there. It is added dynamically at run time, thus not available to static inspection.
Is there any solution for that, or Is there dynamic inspection.
Thanks a lot for your support and your time
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).
A wrapper module that might work for you is DBIx::Wrapper::VerySimple (I wrote it so I am biased)
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.
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.