in reply to DBD::mysql and binding placeholders

This is indeed a common problem, and doing the lookups "manually" in the driver can be difficult.

DBD::Sybase will do the right thing for "normal" placeholders - i.e. for plain SQL statements. This is because the Sybase protocol performs this discovery for you, and so DBD::Sybase knows what type any parameter is (as an aside, this is also why the WHERE (product_code = ? OR (? IS NULL AND product_code IS NULL)) construct does NOT work with Sybase - there is no way to determine the type of the second placeholder!).

For exec some_proc ? statements DBD::Sybase works like MySQL. It would be possible to look up the type of each parameter, but it's an overhead that I didn't want to code into the driver. Hence DBD::Sybase will assume SQL_CHAR unless told otherwise.

The difference with MySQL is that Sybase won't accept a CHAR string where an INT/NUMERIC/FLOAT is expected, and throws an error - so at least you wouldn't be left wondering why it is slow... :-)

Michael

Replies are listed 'Best First'.
Re^2: DBD::mysql and binding placeholders
by theguvnor (Chaplain) on Sep 22, 2004 at 17:03 UTC
    I'm pretty sure that DB2 will also choke if your SQL has a type mismatch. At least it does when accessing it directly; not sure if DBD::DB2 massages things in any way.

    [Jon]

Re^2: DBD::mysql and binding placeholders
by htoug (Deacon) on Sep 23, 2004 at 13:53 UTC
    DBD::Ingres tries to guess by looking at the first bound variable - if it looks like an integer, it is bound like an integer, otherwise as a varchar.

    Not foolproof, but it DWYM most of the time, and in the few times where it fails, you get an error, and have to bind with an explicit type.