DBD-Informix

 view release on metacpan or  search on metacpan

dbdimp.ec  view on Meta::CPAN

                length = strlen(result);
                /* warn("FLOAT Data: %d <<%s>>\n", length, result); */
                break;

            case SQLSMFLOAT:
                EXEC SQL GET DESCRIPTOR :nm_obind VALUE :index
                        :fltval = DATA;
                sprintf(coldata, "%.*g", FLT_DIG, fltval);
                result = coldata;
                length = strlen(result);
                /* warn("SMALLFLOAT Data: %d <<%s>>\n", length, result); */
                break;

            case SQLDECIMAL:
            case SQLMONEY:
                /*
                ** Default formatting (in some versions of ESQL/C)
                ** assumes 2 decimal places -- wrong!
                */
                EXEC SQL GET DESCRIPTOR :nm_obind VALUE :index
                        :decval = DATA;
                strcpy(coldata, decgen(&decval, collength));
                result = coldata;
                length = strlen(result);
                /* warn("Decimal Data: %d <<%s>>\n", length, result); */
                break;

#ifdef SQLUDTFIXED
            case SQLUDTFIXED:
                {
                    EXEC SQL BEGIN DECLARE SECTION;
                    fixed binary ifx_lo_t bclob;
                    EXEC SQL END DECLARE SECTION;
                    char            cb = 'C';
                    int             error = 0;

                    EXEC SQL GET DESCRIPTOR :nm_obind VALUE :index
                                        :extypeid = EXTYPEID;

                    result = NULL;

                    switch (extypeid)
                    {
                    case XID_BLOB:
                        cb = 'B';
                        /* FALLTHROUGH */
                    case XID_CLOB:
                        {
                            int             LO_fd;
                            ifx_lo_stat_t  *LO_stat;
                            ifx_int8_t      size;
                            /* JL 2005-07-27: bloblen is a hack for 64-bit platforms */
                            /* ifx_int8tolong() takes an Informix int4* and not a long*! */
                            int4            bloblen;

                            EXEC SQL GET DESCRIPTOR :nm_obind VALUE :index
                                                :bclob = DATA;
                            LO_fd = ifx_lo_open(&bclob, LO_RDONLY, &error);
                            if (LO_fd == -1)
                                croak("Error opening %cLOB: %d", cb, error);
                            if (ifx_lo_stat(LO_fd, &LO_stat) < 0)
                                croak("Error getting %cLOB stat", cb);
                            if (ifx_lo_stat_size(LO_stat, &size) != 0)
                                croak("Error getting %cLOB size", cb);
                            if (ifx_int8tolong(&size, &bloblen) != 0)
                                croak("Error converting %cLOB size to length", cb);
                            length = bloblen;
                            if (ifx_lo_close(LO_fd) != 0)
                                croak("Error closing %cLOB", cb);
                            if (ifx_lo_to_buffer(&bclob, length, &result, &error) < 0)
                                croak("Error copying from %cLOB", cb);
                            break;
                        }
                    default:
                        length = 0;
                        result = coldata;
                        result[length] = '\0';
                        warn("IUS extended type (%ld) is not yet supported", extypeid);
                        break;
                    }
                    break;
                }
#endif /* SQLUDTFIXED */

#ifdef SQLLVARCHAR
            case CLVCHARPTRTYPE:
            case SQLLVARCHAR:
                if (ifx_var_flag(&lvar, 1) < 0)
                {
                    warn("Cannot set automatic memory for lvarchar");
                    result = coldata;
                    *result = '\0';
                    length = 0;
                    break;
                }
                EXEC SQL GET DESCRIPTOR :nm_obind VALUE :index
                                    :lvar = DATA;
                result = (char *)ifx_var_getdata(&lvar);
                if ((length = ifx_var_getlen(&lvar)) < 0)
                {
                    warn("Length of lvarchar < 0");
                    length = 0;
                    result = coldata;
                    *result = '\0';
                }
                if (result == 0)
                {
                    /* Franky Wong <fwong@seattletimes.com> */
                    result = coldata;
                    *result = '\0';
                    length = 0;
                }
                /**
                ** FW 2002-05-12: Franky Wong <fwong@seattletimes.com>.
                ** JL 2002-12-06: Problem resurfaced because of faulty fix
                ** and reported by Mike Langen <mike.langen@tamedia.ch>.
                ** New test t/t93lvarchar.t should prevent reoccurrences.
                ** Empirical evidence on Solaris 2.6 with CSDK 2.10.UC1
                ** (ESQL/C 9.16.UC1) shows that the LVARCHAR variable is
                ** supplied with 2 NULs '\0' at the end, and both are
                ** counted in the length.  This is also found on Solaris



( run in 2.085 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )