On Wed, Mar 28, 2001 at 10:32:44AM +0200, Steffen Goeldner wrote:
> Tim Bunce wrote:
> >
> > If you tell me which you'd like to see and why, and I like what you say,
> > then your word will be my command (eventually:) !
> >
> > Better still (and faster still), send me a patch!
>
> O.k. The patch is tested for OCI7 and OCI8 on WinNT 4.0, Borland 5.02.
Excellent! Many thanks.
> There are still some options (see comments for SQL_NUMERIC and
> SQL_INTEGER), but this would potentially break more code that
> relies on SQL_DECIMAL and needs additional entries in the
> type_info structure. Any opinions about that?
> - av_store(av, i, newSViv(ora2sql_type(imp_sth->fbh[i].dbtype)));
> + av_store(av, i, newSViv(ora2sql_type(imp_sth->fbh+i).dbtype));
Umm, why change from subscript to pointer arithmetic?
> +static sql_fbh_t
> +ora2sql_type(imp_fbh_t* fbh) {
> + sql_fbh_t sql_fbh;
> + sql_fbh.dbtype = fbh->dbtype;
> + sql_fbh.prec = fbh->prec;
> + sql_fbh.scale = fbh->scale;
> +
> + switch(fbh->dbtype) { /* oracle Internal (not external) types */
> + case SQLT_NUM:
> + if (fbh->scale == -127) { /* FLOAT, REAL, DOUBLE_PRECISION */
> + sql_fbh.dbtype = SQL_DOUBLE;
> + sql_fbh.scale = 0; /* better: undef */
> + }
> + else if (fbh->scale == 0) {
> + if (fbh->prec == 0) { /* NUMBER */
> + sql_fbh.dbtype = SQL_DOUBLE;
> + sql_fbh.prec = 126;
> + }
> + else { /* INTEGER, NUMBER(p,0) */
> + sql_fbh.dbtype = SQL_DECIMAL; /* better: SQL_INTEGER */
> + }
It it possible and useful to distinguish cases where the precision is
small enough to fit in a perl integer? I suspect not because (I think)
declaring a field 'INTEGER' or even 'SMALLINT' in Oracle still defines
it as 'NUMBER(38,0)'. But then people who care could always manually
decalre a field as 'NUMBER(n,0)' where n is small as we could usefully
return SQL_INTEGER then, yes? (If so, want to update the patch? :)
> }
> + else { /* NUMBER(p,s) */
> + sql_fbh.dbtype = SQL_DECIMAL; /* better: SQL_NUMERIC */
> + }
Does anyone know the practical difference between SQL_DECIMAL and
SQL_NUMERIC? The only info I can find seems to relate to their
use in COBOL ('PACKED DECIMAL' vs 'DISPLAY SIGN LEADING SEPARATE').
Tim.