On Tue, Feb 19, 2002 at 10:41:37AM +0100, H.Merijn Brand wrote:
> > >
> > > But have these functions not implemented?
> > > - Place holders
> > 
> > Yes, in CVS, but SQLite doesn't support them, so it uses the hackish
> > method of splitting up the SQL on ? and re-joining it for execution with
> > the values in place. Yucky.
> 
> I admid I've been spending not enough time on the DB[ID] part of my perl
> activities, but didn't someone make some generic XS part for this on a request
> of Tim? IIRC 'bout 6 month ago. A quick browse through the messages I saved
> regarding DBI didn't show anything though.

Try

        use DBI qw(:preparse_flags);

        $sql = $dbh->preparse($sql, DBIpp_ph_sp, DBIpp_ph_qm);

in the latest DBI. That should read the input sql containing '?'
placeholders and return it in a form that can be used for sprintf.
It can do rather more that that, and will do much more in future.
See t/preparse.t for some tests.

It's all a bit new (and undocumented) and currently there's no way
to get other info back like how many placeholders there are. But
after the above you could use a regex that counts %s's that don't
have a preceding %.

Tim.

Reply via email to