DBD-IngresII
view release on metacpan or search on metacpan
case SQL_DOUBLE:
case SQL_NUMERIC:
case SQL_DECIMAL:
type = 2; break;
case SQL_CHAR:
case SQL_BINARY:
case SQL_VARCHAR:
case SQL_VARBINARY:
case SQL_DATE:
/* case SQL_DATETIME: it looks like it is the same as SQL_DATE*/
case SQL_TIME:
case SQL_INTERVAL_YEAR_TO_MONTH:
case SQL_INTERVAL_DAY_TO_SECOND:
type = 3; break;
case SQL_LONGVARCHAR:
case SQL_LONGVARBINARY:
type = 4; break;
default:
croak("DBD::Ingres::bind_param: Unknown TYPE: %ld, param_no %d",
(long)sql_type, param_no);
}
else if (!SvOK(value)) /* NULL */
croak(
"Ingres(bind_param): sorry NULLs not allowed unless TYPE defined");
else if (SvIOK(value)) /* integer */
type = 1;
else if (SvNOK(value)) /* float */
type = 2;
else /* char */
type = 3;
}
if (dbis->debug >= 3)
PerlIO_printf(DBILOGFP, " type=%d\n", type);
var->sqlind = 0;
switch (type)
{
/* This used to have a kind of poor mans memory management, but
* it seems using Renew() each time to change the size of
* the buffer is just as fast and much easier because you
* don't have to worry about the 0 case. */
/* addition: now you have to :( */
case 1: /* int */
if (var->sqltype == IISQ_BOO_TYPE)
{
var->sqllen = sizeof(int);
Renew(var->sqldata, var->sqllen, char);
if (SvOK(value))
*(int *)var->sqldata = (int)SvIV(value);
}
else
{
var->sqllen = sizeof(IV);
Renew(var->sqldata, var->sqllen, char);
if (imp_sth->ing_empty_isnull && ((SvPOK(value) && (SvCUR(value) == 0)) || !looks_like_number(value)))
{
if (dbis->debug >= 2)
PerlIO_printf(DBILOGFP, "### DBD::Ingres::dbd_bind_ph(%d) NaN using NULL\n", param_no);
force_null = 1;
}
else if (SvOK(value))
*(IV *)var->sqldata = SvIV(value);
}
var->sqltype = IISQ_INT_TYPE;
break;
case 2: /* float */
var->sqltype = IISQ_FLT_TYPE;
var->sqllen = sizeof(double);
Renew(var->sqldata, var->sqllen, char);
if (imp_sth->ing_empty_isnull && ((SvPOK(value) && (SvCUR(value) == 0)) || !looks_like_number(value)))
{
if (dbis->debug >= 2)
PerlIO_printf(DBILOGFP, "### DBD::Ingres::dbd_bind_ph(%d) NaN using NULL\n", param_no);
force_null = 1;
}
else if (SvOK(value))
*(double *)var->sqldata = (double)SvNV(value);
break;
case 3: /* string */
{
STRLEN len;
char *string;
var->sqltype = IISQ_VCH_TYPE;
if (SvOK(value))
string = SvPV(value, len);
else
{
string = 0;
len = 0;
}
if (SvOK(value))
{
if (imp_sth->ing_empty_isnull && (SvCUR(value) == 0))
{
string = NULL;
len = 0;
force_null = 1;
}
else
string = SvPV(value, len);
}
var->sqllen = (unsigned short)len;
Renew(var->sqldata, len + sizeof(short), char);
if (SvOK(value) && !force_null)
{
*(short *)var->sqldata = (short)len;
Copy(string, var->sqldata + sizeof(short), len, char);
}
/* This works around a bug in Ingres where inserting byte fields
* as IISQ_VCH_TYPE fails if the strings ends in a \0. It works
* if we use VBYTE_TYPE, but we can't default to that as you
* cannot use it to insert dates. */
if (sql_type == SQL_BINARY)
var->sqltype = IISQ_VBYTE_TYPE;
break;
}
case 4:
/* blob */
{
IISQLHDLR *hdlr;
var->sqltype = IISQ_HDLR_TYPE;
Renew(var->sqldata, sizeof(IISQLHDLR), char);
( run in 3.271 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )