XP is just a number | |
PerlMonks |
SQL/DBIby tomazos (Deacon) |
on Oct 20, 2001 at 09:58 UTC ( [id://120212]=perlquestion: print w/replies, xml ) | Need Help?? |
tomazos has asked for the wisdom of the Perl Monks concerning the following question:
I'm using DBI to talk to a MySQL server.
When preparing SQL statements to send to the server, DBI circumvents the problem of different SQL syntaxes across all the different SQL servers (Oracle, Sybase, MySQL etc) by simply taking the statement as a raw string and letting the SQL server tell you whether the syntax is valid or not. The problem with this is that you don't find out until deep into runtime whether there is a problem with your SQL - even something simple such as a typo. I appreciate that it would be really hard to write a layer over SQL that was general across all servers, but I'm really only interested in MySQL's specific syntax to get my job done. With that as a given, I think it should be possible to write something (perhaps like a CGI.pm style interface to HTML) that will allow you to compile-time check MySQL specific SQL syntax, and perhaps even check if you are refering to real databases and tables. I was thinking something like:
would be equivilant to:
Obviously for this simple example the extra layer is not worth the overhead for clarity's sake - but for a more complex real world situation the compile time syntax checking would be worth it. Has anyone got any thoughts further to this?
Back to
Seekers of Perl Wisdom
|
|