Creating a user-defined function with SQL::Statement::Functions in Perl creates a syntax error -


i trying work udfs, defined through sql::statement::functions in perl mysql database in backend. playing book, stated in http://metacpan.org/pod/sql::statement::functions#user-defined-functions, however, before leave square one, error in create function statement rearing ugly head. here's code first ($dbh given , works fine, part of bigger construct of framework working with, don't want spam question of it; if replace foo() in select 22, or "_pk locations", , 22 or value corresponding query in data::dumper, so, connection ok):

use data::dumper; use sql::statement::functions;  sub foo {     return 999; }  #$dbh defined elsewhere $dbh->do("create function foo") or die "error creating function foo(); " . $dbh->errstr;  $sth = $dbh->prepare("select foo(22)") or die "error preparing query: " . $dbh->errstr; $sth->execute or die "error executing query: " . $sth->errstr;  $row = $sth->fetchrow_arrayref(); print "row " . dumper($row); 

the error message reads follows: error creating function foo(); have error in sql syntax; check manual corresponds mysql server version right syntax use near '' @ line 1, refering $dbh->do("create...") line.

i have tried dumb create function part down as possible, tried ...foo external , ...foo external name foo suggested manual. heck, created package function, no avail.

any ideas doing wrong here?

i checked, , user connected database have privileges, including alter_routine_priv , create_routine_priv, if sql::statement using.

you not using module intended. it's extension sql::parser module used dbds implement sql syntax , functions. documentation states:

this module contains built-in functions sql::parser , sql::statement. of functions available in dbds subclass modules (e.g. dbd::csv, dbd::dbm, dbd::file, dbd::anydata, dbd::excel, etc.).

to me, sounds has nothing mysql. dbd::mysql used wrapper around real mysql database. connects, forwards queries, prepares them , on. not parse them, however. that's database doing, if connect oracle or mssql database. in cases, driver api wrapper.

on other hand, dbd::csv , others mentioned above parsing sql themselves. dbd::csv opens csv file, understands sql , (very described) translates perl code stuff in csv data. same goes others. use sql::parser make sense of sql. sql::statement::functions seems module provides equivalent perl functions sql.

when using sql::statement/sql::parser directly parse sql ...


Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -