sub SQL_FUNCTION_POSITION { my($sth,$rowhash,@params) = @_; return index($params[1],$params[0]) +1; } # e.g. SELECT col1 FROM tbl WHERE POSITION('foo',col2) < 3; #### sub SOUNDEX { my($self,$sth,$rowhash,@params)=@_; use Text::Soundex 'soundex'; my $s1 = soundex($params[0]) or return 0; my $s2 = soundex($params[1]) or return 0; return $s1 eq $s2; } #### use DBI; my $dbh = DBI->connect('dbi:File(RaiseError=1):'); $dbh->do("CREATE FUNCTION $_ EXTERNAL") for qw(Prof Class); sub Prof {[ [qw(pid pname)],[qw(1 Sue )],[qw(2 Bob)],[qw(3 Tom )] ]} sub Class {[ [qw(pid cname)],[qw(1 Chem)],[qw(2 Bio)],[qw(2 Math)] ]} $sth = $dbh->prepare("SELECT * FROM Prof NATURAL JOIN Class"); $sth->execute; $sth->dump_results; #### $sth = $dbh->prepare("SELECT * FROM _1(?) AS x NATURAL JOIN _2(?) AS y"); $sth->execute( $pg_sth, $mysql_sth);