in reply to Re: DBI::Shell sqlite dbh->func(
in thread DBI::Shell sqlite dbh->func(
If I try it without the single quotes within the func declaration, I get a strict subs error
Now how to get DBI::Shell to interact with the user so they have access to this function?
#!/usr/bin/perl -w # create a SQLite test database use strict; use DBI; my $db = shift || 'no_name.splite'; my $dbh = DBI->connect("dbi:SQLite:$db", "","", {RaiseError => 1, sqlite_see_if_its_a_number => 1, PrintError=>0}) or die "can't connect\n"; $dbh->func('sqrt_s_s', -1, 'sqrt_sum_of_sqrs', 'create_function'); #ne +ed length function sub sqrt_sum_of_sqrs { my $sum_sqrs = 0.0; map {$sum_sqrs += $_**2} @_; return sqrt($sum_sqrs); } my $sth; my @rowa = $dbh->selectrow_array("select 3 as A,4 as B, sqrt_s_s(3,4) +as C"); print join ("\t",@rowa) ;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: DBI::Shell sqlite dbh->func(
by Mr. Muskrat (Canon) on Oct 23, 2013 at 16:24 UTC | |
by rodinski (Novice) on Oct 31, 2013 at 01:50 UTC |