Any opinions?  Is there another approach that I should think about?  Has
anyone encountered this situation before?

For most selects it isn't that hard to turn metadata about the query into vendor SQL. The simplest fix may be hiding the queries behind another object that takes in generic selects and spits out SQL appropriate for the particular DBD::Foobar.

I should have an alpha version of Plugin::Installer and
Plugin::Language::DML avaialble in a week. The plugins
could be various collections of metadata indexed by common
names (a.k.a. hash keys). You then use something like:

        my $dblink = $dbhandler_class->construct;
        ...
        
        $dblink->frobnicate( @argz );

With the various handler classes defining the
metadata-to-query handler for that particular
database. You only store the metadata once,
the if-logic is isolated into a single place.

That can easily be shoved into a single factory
class:

        sub construct
        {
                shift;

                my $connect_meta = shift;

                my $handler_class =
                do
                {
                        if( ... )
                        {
                                'Oracle::Query'
                        }
                        elsif( ... )
                        {
                                'MySQL::Query'
                        }
                        else
                        {
                                croak "Bogus query: unable to determine class 
from:",
                                        @$connect_meta;
                        }
                };

                # caller gets back whatever the appropriate
                # class constructs with the connection data.

                $handler_class->construct( @$connect_meta );
        }

The handler classes all implement a few hooks like
"run_query" and "commit":

        my $handler = Factory->construct;

        ...

        $handler->run_query( query_name => [ query argz ] );
        $handler->commit;

The run_query could either construct SQL from scratch
or munge ANSI to handle special cases.

--
Steven Lembark                                       85-09 90th Street
Workhorse Computing                                Woodhaven, NY 11421
[EMAIL PROTECTED]                                     1 888 359 3508

Reply via email to