> -----Original Message----- > From: Dennis Cote [mailto:[EMAIL PROTECTED] > Sent: Thursday, January 22, 2004 5:23 PM > To: Williams, Ken; [EMAIL PROTECTED] > Subject: Re: [sqlite] Functions & Keywords > > > Again, see the SQLite source, in particular the file func.c, > for examples of > how to use these calls.
Hmm - all of those functions seem to depend only on their argument input, making no external calls to the database. How would I implement, for example, a stored procedure that performs several inserts/selects on several database tables? I tried a little experiment with the Perl interface (which uses the sqlite_create_function() call under the hood), and the function I created just hangs when it's called. Is SQLite not re-entrant in this way, or is this a peculiarity of the Perl interface? My code is below. -Ken -------------------------------------------------------- use strict; use DBI; my $dbh = DBI->connect('dbi:SQLite:dbname=test', undef, undef, {RaiseError => 1}); $dbh->do("CREATE TABLE foo (a, b)"); $dbh->do("INSERT INTO foo VALUES (1, 2)"); $dbh->do("INSERT INTO foo VALUES (2, 4)"); $dbh->func( 'get_b', 1, sub { warn "Called the function"; my ($x) = $dbh->selectrow_array ("SELECT b FROM foo WHERE a=$_[0]"); return $x }, 'create_function'); my $a = $dbh->selectall_arrayref ("SELECT a, get_b(a) FROM foo"); print "@$_\n" foreach @$a; --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]