Embedded SQL and Converting SQLDTIME to ASCII
Posted in 1998
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL
I am trying to convert a SQLDTIME to an ascii string using Embedded SQL in C. I am initializing the sqldata pointers in the following manner: fldCount = qSQLDA->sqld; if (fldCount > 0) { int bufferSize = 0; for(int i = 0; i < fldCount; i++) { switch (qSQLDA->sqlvar[i].sqltype) { case SQLDTIME: case SQLINTERVAL: case SQLDECIMAL: case SQLMONEY: qSQLDA->sqlvar[i].sqllen = rtypmsize(qSQLDA->sqlvar[i].sqltype, CDECIMALTYPE); break; default: qSQLDA->sqlvar[i].sqllen = rtypmsize(qSQLDA->sqlvar[i].sqltype, qSQLDA->sqlvar[i].sqllen); break; } bufferSize = rtypalign(bufferSize, qSQLDA->sqlvar[i].sqltype) + qSQLDA->sqlvar[i].sqllen; } dataBuffer = (char *) malloc(bufferSize); memset(dataBuffer, 0, bufferSize); if (dataBuffer == 0) { errCode = -1; return errCode; } int pos = 0; for (int j = 0; j < fldCount; j++) { pos = rtypalign(pos, qSQLDA->sqlvar[j].sqltype); qSQLDA->sqlvar[j].sqldata = &dataBuffer[pos]; pos += qSQLDA->sqlvar[j].sqllen; } } I have tried many different forms of setting the sqllen for the SQLDTIME field, including: - rtypmsize(qSQLDA->sqlvar[i].sqltype, CDECIMALTYPE); - sizeof(dtime_t); - rtypmsize(qSQLDA->sqlvar[i].sqltype, 24); /* found this somewhere */ - and, just leaving it as is (the default). I have tried to convert the SQLDTIME field to ascii with the following: case SQLDTIME: dttoasc((dtime_t *) qSQLDA->sqlvar[i].sqldata, colData); break; This gives me the following value in colData: -00-00 00 The actual value in this field is: 1998-06-18 11:25:40 I have also tried the following: case SQLDTIME: dtime_t * sqlDateTime; sqlDateTime = ((dtime_t *) qSQLDA->sqlvar[i].sqldata; sqlDateTime->dt_qual = qSQLDA->sqlvar[i].sqllen; dtcvasc(colData, sqlDateTime); break; This gives me an empty string in colData. I have looked at many examples and tried many different ways to get this to work. I am getting fairly frustrated. I have all other field types converted to ASCII, it is just this one that is giving me problems. Any help would be greatly appreciated. TIA, Tracy -----== Posted via Deja News, The Leader in Internet Discussion ==----- http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum