On Thu, May 12, 2005 at 08:34:14AM -0700, Dean Arnold wrote: > > =item C<ParamTypes> (hash ref, read-only) > > Returns a reference to a hash containing the type information > currently bound to placeholders. The keys of the hash are the > 'names' of the placeholders: either integers starting at 1, or, > for drivers that support named placeholders, the actual parameter > name string. The hash values are hashrefs of type information in > the same form as that provided to the various bind_param() methods > (See L</"Data Types for Placeholders"> for the format and values), > plus anything else that was passed as the third argument to bind_param(). > Note that type information that is not relevant to a given > TYPE may be omitted, e.g., SCALE for SQL_CHAR. > > [ NOTE TO TIM: Your note in the roadmap shows both the scalar and > hashref form of type info...in the interest of simplicity, I'd prefer > a single form (hashrefs); do you have a strong opinion one way > or the other ? ]
The goal is to keep bind_param cheap. But drivers can defer the cost of converting the scalar to a hash ref till the ParamTypes attribute is accessed. > Returns undef if not supported by the driver. > > [ NOTE TO TIM: Do you envision adding this info to the > ShowErrorStatement output ?] No. > See L</ShowErrorStatement> for an example of how this is used. > > If the driver supports C<ParamTypes>, but no values have been bound > yet, then the driver should return a hash with the placeholder name > keys, but all the values undef; however, some drivers may return > a ref to an empty hash, or, alternately, may provide full type > information (e.g., if the prepare()'d SQL statement provides placeholder > type information). > > It is possible that the values in the hash returned by C<ParamTypes> > are not I<exactly> the same as those passed to bind_param() or execute(). > The driver may have modified the type information in some way based > on the bound values, other hints provided by the prepare()'d > SQL statement, or alternate type mappings required by the driver or target > database system. > > It is also possible that the keys in the hash returned by C<ParamTypes> > are not exactly the same as those implied by the prepared statement. > For example, DBD::Oracle translates 'C<?>' placeholders into 'C<:pN>' > where N is a sequence number starting at 1. > > The C<ParamTypes> attribute was added in DBI X.XX. Implementation > is the responsibility of individual drivers; the DBI layer default > implementation simply returns undef. All seems fine. You can send the patch direct to me and I'll apply it. Or, if you give me your perl.org userid I'll give you commit rights[*] Tim. [*] I've decided to be more liberal with commit access than I have been in the past. I'll give commit access now to anyone with a track record of sane patches.