Saturday, July 08, 2006

 

Perl 6 DBI update

There is quite a lot of progress since my last report, I'm happy to say.

I've turned my attention towards Error Handling & Management, which happened to be tricky for multiple reasons. JDBC is Java, so it uses Throwable objects to throw exceptions. Inline::Java, which JDBC.pm is based on, uses the caught() method, eval and $@ to pass these exceptions to the Perl 5 side. Then I needed to trap these exceptions in Perl6 land.

Thanks to audrey++ for implementing my requests, so that now Pugs can handle unclaimed dies from perl5 land, caught by try { }, pass $@ as $!, and deal with the contents of $! if it happens to be a reference to the Throwable object dealing with the given exception (test here).

Another reason Error Handling is tricky, is because JDBC doesn't know the concept of a 'current error', but DBI has ($h->err), so there is a dispatch layer needed to handle the Error handling methods. I've written the exception handling part to trap JDBC errors, and a basic set_err method, currently works with RaiseError on.

I've also updated the Statement class's execute method, so that it can deal with SELECT and non-SELECT statements now aswell. On non-SELECT statements it returns the updated row count, if available. On SELECT statements it returns a true value.

To be able to retrieve the results of a SELECT statement, I've implemented fetchrow_arrayref in the Statement class.

Next, I'll work on getting more done from error handling & management, and when it reached a more reasonable state I'll start working on implementing prepared statements, with placeholders.

Comments: Post a Comment



<< Home

This page is powered by Blogger. Isn't yours?