Changeset 9d6a77b in tol


Ignore:
Timestamp:
Jan 12, 2016, 5:11:27 PM (11 years ago)
Author:
Jorge Pérez <josp.jorge@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
9b74047
Parents:
eb0481b
Message:

refs #1906, se usan los tipos adecuados SQLLEN, se corrige la conversion de fraction a msecond

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@7190 be4846ae-f051-483a-831f-b64e7d08527f

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tol/dbdrivers/libtolodbc.c

    reb0481b r9d6a77b  
    426426{
    427427  SQLRETURN status;
    428   SQLINTEGER row_count=-1;
     428  SQLLEN row_count=-1;
    429429 
    430430  if(odbc_OpenQuery(dbd, query))
    … …  
    473473  SQLCHAR szColName [SQLMAXWORD+1];
    474474  SQLSMALLINT pfSqlType, pibScale, pfNullable;
    475   SQLUINTEGER pcbColDef;
     475  SQLULEN ColumnSize;
    476476  SQLRETURN status;
    477477  int ret = TypeDBUnknown;
    478478 
    479479  status = SQLDescribeCol(dbd->hstmt, nfield+1, szColName, SQLMAXWORD, NULL,
    480                           &pfSqlType, &pcbColDef, &pibScale, &pfNullable);
     480                          &pfSqlType, &ColumnSize, &pibScale, &pfNullable);
    481481  if(!checkSQLRet(status, dbd, __LINE__, GET_DIAG_STMT)) {
    482482    return -1;
    … …  
    484484
    485485  dbd->typeList[nfield] = pfSqlType;
    486   //printf( "pfSqlType=%d\n", pfSqlType );
     486  // printf( "pfSqlType=%d\n", pfSqlType );
    487487  switch (pfSqlType)
    488488    {
    … …  
    524524
    525525  SQLSMALLINT pfSqlType;
    526   SQLUINTEGER pcbColDef;
     526  SQLULEN ColumnSize;
    527527  SQLSMALLINT pibScale;
    528528  SQLSMALLINT pfNullable;
    … …  
    530530  status = SQLDescribeCol(dbd->hstmt, nfield+1,
    531531                          (SQLCHAR*)fieldName, SQLMAXWORD, NULL,
    532                           &pfSqlType, &pcbColDef,
     532                          &pfSqlType, &ColumnSize,
    533533                          &pibScale, &pfNullable);
    534534
    … …  
    596596  // variables for SQLGetData function
    597597  SQLPOINTER pointer;
    598   SQLINTEGER pcbValue;
     598  SQLLEN pcbValue;
    599599  int size;
    600600  char szErrMsg[256];
    … …  
    690690{
    691691  SQLRETURN status;
    692   SQLINTEGER num_available=0, num_required=MAX_TEXT_FIELD_LENGTH;
     692  SQLINTEGER num_required=MAX_TEXT_FIELD_LENGTH;
     693  SQLLEN num_available=0;
    693694  UCHAR *str, *long_str;
    694695
    … …  
    743744
    744745  SQLPOINTER pointer;
    745   SQLINTEGER pcbValue;
     746  SQLLEN pcbValue;
    746747  int size;
    747748  char *errmsg;
    … …  
    773774    case SQL_TYPE_TIMESTAMP:
    774775#endif
     776      // printf( "preparing to extract SQL_TYPE_TIMESTAMP\n" );
    775777      size        = sizeof(struct tagTIMESTAMP_STRUCT);
    776778      x_timestamp = (struct tagTIMESTAMP_STRUCT *)malloc(size);
    … …  
    794796    return 0;
    795797  }
    796 
    797798  /* pcbValue must be the length of the data available to return.
    798799   * But also can be:
    … …  
    827828    case SQL_TYPE_TIMESTAMP:
    828829#endif
     830#ifdef __DUMP_TIMESTAMP__
     831      printf( "year = %hd\n", x_timestamp->year );
     832      printf( "month = %hd\n", x_timestamp->month );
     833      printf( "day = %hd\n", x_timestamp->day );
     834      printf( "hour = %hd\n", x_timestamp->hour );
     835      printf( "minute = %hd\n", x_timestamp->minute );
     836      printf( "second = %hd\n", x_timestamp->second );
     837      printf( "fraction = %d\n", x_timestamp->fraction );
     838#endif
    829839      (*dateval)->year    = (unsigned short)(x_timestamp->year);
    830840      (*dateval)->month   = (unsigned short)(x_timestamp->month);
    … …  
    833843      (*dateval)->minute  = (unsigned short)(x_timestamp->minute);
    834844      (*dateval)->second  = (unsigned short)(x_timestamp->second);
    835       (*dateval)->msecond = (unsigned short)(x_timestamp->fraction);
     845      // The fraction of a second, in billionths of a second.  Possible values are 0 to 999,999,999.
     846      //(*dateval)->msecond = (unsigned short)(x_timestamp->fraction);
     847      if ( x_timestamp->fraction > 999999999 )
     848        {
     849        (*dateval)->msecond = 999;
     850        }
     851      else
     852        {
     853        (*dateval)->msecond = (unsigned short)(x_timestamp->fraction/1000000.0);
     854        }
     855#ifdef __DUMP_TIMESTAMP__
     856      printf( "(*dateval)->msecond = %d\n", (*dateval)->msecond );
     857#endif
    836858    }
    837859 
Note: See TracChangeset for help on using the changeset viewer.