trafodion-codereview mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From DaveBirdsall <...@git.apache.org>
Subject [GitHub] trafodion pull request #1310: [TRAFODION-2816] ODBC data convert function sp...
Date Mon, 05 Feb 2018 19:59:44 GMT
Github user DaveBirdsall commented on a diff in the pull request:

    https://github.com/apache/trafodion/pull/1310#discussion_r166092390
  
    --- Diff: core/conn/unixodbc/odbc/odbcclient/unixcli/cli/ctosqlconv.cpp ---
    @@ -1036,2500 +1166,3031 @@ unsigned long ODBC::ConvertCToSQL(SQLINTEGER	ODBCAppVersion,
                             DataLen = sizeof(SCHAR);
                         }
                         break;
    -				case SQL_SMALLINT:
    -					if (targetUnsigned)
    -					{
    -						if ( dTmp < 0 )
    -							return IDS_22_003_02;  //negValue in unsigned column
    -						if (dTmp > USHRT_MAX)
    -							return IDS_22_003;
    -						usTmp = (USHORT)dTmp;
    -						if  (dTmp != usTmp)
    -							retCode = IDS_01_S07;
    -						DataPtr = &usTmp;
    -						DataLen = sizeof(usTmp);
    -					}
    -					else
    -					{
    -						if (unsignedInteger)
    -						{
    -							if (dTmp < 0 || dTmp > USHRT_MAX)
    -								return IDS_22_003;
    -							sTmp = (SHORT)dTmp;
    -						}
    -						else
    -						{
    -							if (dTmp < SHRT_MIN || dTmp > SHRT_MAX)
    -								return IDS_22_003;
    -							sTmp = (SHORT)dTmp;
    -							if  (dTmp != sTmp)
    -								retCode = IDS_01_S07;
    -						}
    -						DataPtr = &sTmp;
    -						DataLen = sizeof(sTmp);
    -					}
    -					break;
    -				case SQL_INTEGER:
    -					if (targetUnsigned)
    -					{
    -						if (dTmp < 0)
    -							return IDS_22_003_02;//negValue in unsigned col error
    -						if (dTmp > UINT_MAX )
    -							return IDS_22_003;
    -						ulTmp = (ULONG_P)dTmp;
    -						if  (dTmp != ulTmp)
    -							retCode = IDS_01_S07;
    -						DataPtr = &ulTmp;
    -						DataLen = sizeof(ulTmp);
    -					}
    -					else
    -					{
    -						if (unsignedInteger)
    -						{
    -							if (dTmp < 0 || dTmp > UINT_MAX )
    -								return IDS_22_003;
    -							lTmp = (LONG)dTmp;
    -						}
    -						else
    -						{
    -							if (dTmp < LONG_MIN || dTmp > INT_MAX)
    -								return IDS_22_003;
    -							lTmp = (LONG)dTmp;
    -							if  (dTmp != lTmp)
    -								retCode = IDS_01_S07;
    -						}
    -						DataPtr = &lTmp;
    -						DataLen = sizeof(lTmp);
    -					}
    -					break;
    -				case SQL_REAL:
    -					if (dTmp < -FLT_MAX || dTmp > FLT_MAX)
    -						return IDS_22_003;
    -					fltTmp = (SFLOAT)dTmp;
    -					DataPtr = &fltTmp;
    -					DataLen = sizeof(fltTmp);
    -					break;
    -				case SQL_DOUBLE:
    -				case SQL_FLOAT:
    -					DataPtr = &dTmp;
    -					DataLen = sizeof(dTmp);
    -					break;
    -				case SQL_DECIMAL:
    -					if (targetPrecision >= sizeof(cTmpBuf))
    -						return IDS_22_003;
    -#if defined MXHPUX || defined MXOSS || defined MXAIX || MXSUNSPARC || MXSUNSPARC
    -					dTmp1 = pow((double)10,targetPrecision-targetScale+1);
    -#else
    -					dTmp1 = pow(10,targetPrecision-targetScale+1);
    -#endif
    -					if (targetUnsigned)
    -					{
    -						if ( dTmp < 0 )
    -							return IDS_22_003_02;  //negValue in unsigned column
    -						if (dTmp > dTmp1)
    -							return IDS_22_003;
    -
    -						tempPtr = _fcvt(dTmp, targetScale, &dec, &sign);
    -						tempLen = strlen(tempPtr);
    -						tempLen1 = (short)(targetPrecision-tempLen);
    -
    -						if (tempLen1 < 0)
    -							return IDS_22_003;
    -
    -						memset((void *)cTmpBuf, '0', tempLen1);
    -						strncpy((char *)(cTmpBuf+tempLen1), tempPtr, tempLen);
    -					}
    -					else
    -					{
    -						if (dTmp < -dTmp1 || dTmp > dTmp1)
    -							return IDS_22_003;
    -
    -						tempPtr = _fcvt(dTmp, targetScale, &dec, &sign);
    -						tempLen = strlen(tempPtr);
    -						tempLen1 = (short)(targetPrecision-tempLen);
    -
    -						if (tempLen1 < 0)
    -							return IDS_22_003;
    -
    -						memset((void *)cTmpBuf, '0', tempLen1);
    -						strncpy((char *)(cTmpBuf+tempLen1), tempPtr, tempLen);
    -						if (sign)
    -							*cTmpBuf = (UCHAR)(*cTmpBuf | (UCHAR)0x80);
    -					}
    -					DataPtr = cTmpBuf;
    -					DataLen = targetPrecision;
    -					break;
    -				default:
    -					return IDS_07_006;
    -				}
    -			}
    -			else
    -			{
    -				if (targetScale)
    -				{
    -					for (i = 0,tempVal64 = 1; i < targetScale ;  i++)
    -						tempVal64 *= 10;
    -					tempVal64 = tempVal64 * integralPart;
    -					decimalDigits = 0;
    -					if (decimalPart > 0)
    -						decimalDigits = getDigitCount(decimalPart);
    -					scaleOffset = 0;
    -					if (leadZeros < targetScale)
    -					  scaleOffset = targetScale - decimalDigits - leadZeros;
    -					if (scaleOffset < 0)
    -					{
    -//NUMERIC_VALUE_OUT_OF_RANGE_ERROR
    -						return IDS_22_003;
    -					}
    -					for (i =0, tempScaleVal64 = decimalPart ; i < scaleOffset ; i++)
    -						tempScaleVal64 *= 10;
    -					tempVal64 += tempScaleVal64;
    -				}
    -				else
    -				{
    -//NUMERIC_DATA_TRUNCATED_ERROR
    -					if (decimalPart != 0)
    -						retCode = IDS_01_S07;
    -					tempVal64 = integralPart;
    -				}
    -				if (negative)
    -					tempVal64 = -tempVal64;
     
    -				switch( SQLDataType )
    -				{
    -                case SQLTYPECODE_TINYINT_UNSIGNED:
    -                    if (tempVal64 < 0)
    -                        return IDS_22_003_02;
    -                    if (tempVal64 > UCHAR_MAX)
    -                        return IDS_22_003;
    -                    utTmp = (UCHAR)tempVal64;
    -                    if  (tempVal64 != utTmp)
    -                        retCode = IDS_01_S07;
    -                    DataPtr = &utTmp;
    -                    DataLen = sizeof(UCHAR);
    -                    break;
    -                case SQLTYPECODE_TINYINT:
    -                    if (tempVal64 < SCHAR_MIN || tempVal64 > SCHAR_MAX)
    -                        return IDS_22_003;
    -                    tTmp = (SCHAR)tempVal64;
    -                    if  (tempVal64 != tTmp)
    -                        retCode = IDS_01_S07;
    -                    DataPtr = &tTmp;
    -                    DataLen = sizeof(SCHAR);
    +                case SQL_SMALLINT:
    +                    if (targetUnsigned)
    +                    {
    +                        if (dTmp < 0)
    +                            return IDS_22_003_02;  //negValue in unsigned column
    +                        if (dTmp > USHRT_MAX)
    +                            return IDS_22_003;
    +                        usTmp = (USHORT)dTmp;
    +                        if  (dTmp != usTmp)
    +                            retCode = IDS_01_S07;
    +                        DataPtr = &usTmp;
    +                        DataLen = sizeof(USHORT);
    +                    }
    +                    else
    +                    {
    +                        if (!signedInteger)
    +                        {
    +                            if (dTmp < 0 || dTmp > USHRT_MAX)
    +                                return IDS_22_003;
    +                            sTmp = (SHORT)dTmp;
    +                        }
    +                        else
    +                        {
    +                            if (dTmp < SHRT_MIN || dTmp > SHRT_MAX)
    +                                return IDS_22_003;
    +                            sTmp = (SHORT)dTmp;
    +                            if  (dTmp != sTmp)
    +                                retCode = IDS_01_S07;
    +                        }
    +                        DataPtr = &sTmp;
    +                        DataLen = sizeof(SHORT);
    +                    }
                         break;
    -				case SQLTYPECODE_SMALLINT_UNSIGNED:
    -					if (tempVal64 < 0)
    -					       return IDS_22_003_02;
    -					if ((USHORT)tempVal64 > USHRT_MAX)
    -						return IDS_22_003;
    -					usTmp = (USHORT)tempVal64;
    -					if  (tempVal64 != usTmp)
    -						retCode = IDS_01_S07;
    -					DataPtr = &usTmp;
    -					DataLen = sizeof(USHORT);
    -					break;
    -				case SQLTYPECODE_SMALLINT:
    -					if (tempVal64 < SHRT_MIN || tempVal64 > SHRT_MAX)
    -						return IDS_22_003;
    -					sTmp = (SHORT)tempVal64;
    -					if  (tempVal64 != sTmp)
    -						retCode = IDS_01_S07;
    -					DataPtr = &sTmp;
    -					DataLen = sizeof(sTmp);
    -					break;
    -				case SQLTYPECODE_INTEGER_UNSIGNED:
    -					if (tempVal64 < 0)
    -					       return IDS_22_003_02;
    -					if ((ULONG_P)tempVal64 > ULONG_MAX)
    -						return IDS_22_003;
    -					ulTmp = (ULONG_P)tempVal64;
    -					if  (tempVal64 != ulTmp)
    -						retCode = IDS_01_S07;
    -					DataPtr = &ulTmp;
    -					DataLen = sizeof(ulTmp);
    -					break;
    -				case SQLTYPECODE_INTEGER:
    -					if (tempVal64 < LONG_MIN || tempVal64 > LONG_MAX)
    -						return IDS_22_003;
    -					lTmp = (LONG)tempVal64;
    -					if  (tempVal64 != lTmp)
    -						retCode = IDS_01_S07;
    -					DataPtr = &lTmp;
    -					DataLen = sizeof(lTmp);
    -					break;
    -				case SQLTYPECODE_IEEE_FLOAT:
    -					if (tempVal64 < -FLT_MAX || tempVal64 > FLT_MAX)
    -						return IDS_22_003;
    -					fltTmp = (FLOAT)tempVal64;
    -					if  (tempVal64 != fltTmp)
    -						retCode = IDS_01_S07;
    -					DataPtr = &fltTmp;
    -					DataLen = sizeof(fltTmp);
    -					break;
    -				case SQLTYPECODE_IEEE_DOUBLE:
    -					if (tempVal64 < -DBL_MAX || tempVal64 > DBL_MAX)
    -						return IDS_22_003;
    -					dTmp = (DOUBLE)tempVal64;
    -					if  (tempVal64 != dTmp)
    -						retCode = IDS_01_S07;
    -					DataPtr = &dTmp;
    -					DataLen = sizeof(dTmp);
    -					break;
    -				case SQLTYPECODE_DECIMAL_UNSIGNED:
    -				case SQLTYPECODE_DECIMAL_LARGE_UNSIGNED: // Tandem extension
    -					if(negative)
    -						return IDS_22_003_02;
    -				case SQLTYPECODE_DECIMAL:
    -				case SQLTYPECODE_DECIMAL_LARGE: // Tandem extension
    -					if(negative)
    -						tempVal64 = -tempVal64;
    -#if defined MXHPUX || defined MXOSS || defined MXAIX || MXSUNSPARC || MXSUNSPARC
    -					sprintf(cTmpBuf, "%0*lld", targetPrecision, tempVal64);
    -#elif defined unixcli
    -					sprintf(cTmpBuf, "%0*Ld", targetPrecision, tempVal64);
    -#else
    -					sprintf(cTmpBuf, "%0*I64d", targetPrecision, tempVal64);
    -#endif
    -					if (negative)
    -						*cTmpBuf = (UCHAR)(*cTmpBuf | (UCHAR)0x80);
    -					DataPtr = cTmpBuf;
    -					DataLen = strlen(cTmpBuf);
    -					break;
    -				case SQLTYPECODE_LARGEINT:
    -				default:
    -					DataPtr = &tempVal64;
    -					DataLen = sizeof(tempVal64);
    -					break;
    -				}
    -			}
    -		}
    -		else
    -		{
    -			switch (ODBCDataType)
    -			{
    -            case SQL_TINYINT:
    -                DataLen = sizeof(SCHAR);
    -                break;
    -			case SQL_SMALLINT:
    -				DataLen = sizeof(SHORT);
    -				break;
    -			case SQL_INTEGER:
    -				DataLen = sizeof(LONG);
    -				break;
    -			case SQL_REAL:
    -				DataLen = sizeof(FLOAT);
    -				break;
    -			case SQL_DOUBLE:
    -			case SQL_FLOAT:
    -				DataLen = sizeof(DOUBLE);
    -				break;
    -			default:
    -				return IDS_07_006;
    -			}
    -		}
    -		break;
    -	case SQL_BIGINT:
    -		switch (CDataType)
    -		{
    -		case SQL_C_WCHAR:
    -			if (iconv->isAppUTF16())
    -			{
    -				if (srcLength != SQL_NTS)
    -					srcLength = srcLength/2;
    -				// translate from UTF16
    -				if (iconv->WCharToUTF8((UChar*)srcDataPtr, srcLength, srcDataLocale, sizeof(srcDataLocale), (int*)&translateLength, (char*)errorMsg) != SQL_SUCCESS)
    -					return IDS_193_DRVTODS_ERROR;
    -				srcDataPtr = srcDataLocale;
    -				srcLength = translateLength;
    -			}
    -		case SQL_C_CHAR:
    -			{
    -				retCode = ConvertCharToInt64(srcDataPtr, srcLength, tempVal64);
    -				if (retCode != SQL_SUCCESS)
    -					return retCode;
    -			}
    -			break;
    -		case SQL_C_SHORT:
    -		case SQL_C_SSHORT:
    -			tempVal64 = *(SSHORT *)srcDataPtr;
    -			break;
    -		case SQL_C_USHORT:
    -			tempVal64 = *(USHORT *)srcDataPtr;
    -			break;
    -		case SQL_C_TINYINT:
    -		case SQL_C_STINYINT:
    -			tempVal64 = *(SCHAR *)srcDataPtr;
    -			break;
    -		case SQL_C_UTINYINT:
    -		case SQL_C_BIT:
    -			tempVal64 = *(UCHAR *)srcDataPtr;
    -			break;
    -		case SQL_C_SLONG:
    -		case SQL_C_LONG:
    -			tempVal64 = *(SLONG_P *)srcDataPtr;
    -			break;
    -		case SQL_C_ULONG:
    -			tempVal64 = *(ULONG_P *)srcDataPtr;
    -			break;
    -		case SQL_C_FLOAT:
    -			tempVal64 = *(SFLOAT *)srcDataPtr;
    -			break;
    -		case SQL_C_DOUBLE:
    -			tempVal64 = *(DOUBLE *)srcDataPtr;
    -			break;
    -		case SQL_C_BINARY:
    -			DataPtr = srcDataPtr;
    -			break;
    -		case SQL_C_DEFAULT:
    -			if (ODBCAppVersion >= SQL_OV_ODBC3)
    -				DataPtr = srcDataPtr;
    -			else
    -			{
    -				retCode = ConvertCharToInt64(srcDataPtr, srcLength, tempVal64);
    -				if (retCode!= SQL_SUCCESS)
    -					return retCode;
    -			}
    -			break;
    -		case SQL_C_SBIGINT:
    -			tempVal64 = *(__int64 *)srcDataPtr;
    -			break;
    -		case SQL_C_NUMERIC:
    -			ConvertCNumericToChar((SQL_NUMERIC_STRUCT*)srcDataPtr, cTmpBuf);
    -			srcLength = strlen(cTmpBuf);
    -			retCode = ConvertCharToInt64((char*)cTmpBuf, srcLength, tempVal64);
    -			if (retCode != SQL_SUCCESS)
    -				return retCode;
    -			break;
    -		case SQL_C_INTERVAL_MONTH:
    -			intervalTmp = (SQL_INTERVAL_STRUCT *)srcDataPtr;
    -			if (intervalTmp->interval_sign == SQL_TRUE)
    -				tempVal64 = -(intervalTmp->intval.year_month.month);
    -			else
    -				tempVal64 = intervalTmp->intval.year_month.month;
    -			break;
    -		case SQL_C_INTERVAL_YEAR:
    -			intervalTmp = (SQL_INTERVAL_STRUCT *)srcDataPtr;
    -			if (intervalTmp->interval_sign == SQL_TRUE)
    -				tempVal64 = -(intervalTmp->intval.year_month.year);
    -			else
    -				tempVal64 = intervalTmp->intval.year_month.year;
    -			break;
    -		case SQL_C_INTERVAL_DAY:
    -			intervalTmp = (SQL_INTERVAL_STRUCT *)srcDataPtr;
    -			if (intervalTmp->interval_sign == SQL_TRUE)
    -				tempVal64 = -(intervalTmp->intval.day_second.day);
    -			else
    -				tempVal64 = intervalTmp->intval.day_second.day;
    -			break;
    -		case SQL_C_INTERVAL_HOUR:
    -			intervalTmp = (SQL_INTERVAL_STRUCT *)srcDataPtr;
    -			if (intervalTmp->interval_sign == SQL_TRUE)
    -				tempVal64 = -(intervalTmp->intval.day_second.hour);
    -			else
    -				tempVal64 = intervalTmp->intval.day_second.hour;
    -			break;
    -		case SQL_C_INTERVAL_MINUTE:
    -			intervalTmp = (SQL_INTERVAL_STRUCT *)srcDataPtr;
    -			if (intervalTmp->interval_sign == SQL_TRUE)
    -				tempVal64 = -(intervalTmp->intval.day_second.minute);
    -			else
    -				tempVal64 = intervalTmp->intval.day_second.minute;
    -			break;
    -		case SQL_C_INTERVAL_SECOND:
    -			intervalTmp = (SQL_INTERVAL_STRUCT *)srcDataPtr;
    -			if (intervalTmp->interval_sign == SQL_TRUE)
    -				tempVal64 = -(intervalTmp->intval.day_second.second);
    -			else
    -				tempVal64 = intervalTmp->intval.day_second.second;
    -			break;
    -		default:
    -			return IDS_07_006;
    -		}
    -		if (DataPtr == NULL)
    -			DataPtr = &tempVal64;
    -		DataLen = sizeof(tempVal64);
    -		break;
    -	case SQL_NUMERIC:
    -		// sol 10-0820-5315
    -		// for R2.3 SP2 release BigNum is only supported for the following data type
    -		//     SQL_C_DEFAULT, SQL_C_CHAR, SQL_C_FLOAT, SQL_C_DOUBLE
    -		// other data types will be supported in future release(?) need to reject them now
    -		if (((SQLDataType == SQLTYPECODE_NUMERIC) && (targetPrecision > 18)) ||
    -			((SQLDataType == SQLTYPECODE_NUMERIC_UNSIGNED) && (targetPrecision > 9)))
    -		{ //Bignum
    -			switch (CDataType)
    -			{
    -				case SQL_C_DEFAULT:
    -				case SQL_C_CHAR:
    -				case SQL_C_WCHAR:
    -				case SQL_C_FLOAT:
    -				case SQL_C_DOUBLE:
    -				case SQL_C_NUMERIC:
    -					break;
    -				default:
    -					return IDS_S1_006;
    -			}
    -		}
    -		switch (CDataType)
    -		{
    -		case SQL_C_DEFAULT:
    -			if (ODBCAppVersion >= SQL_OV_ODBC3)
    -			{
    -
    -			}						// Want it fall thru and treat it like SQL_C_CHAR
    -		case SQL_C_WCHAR:
    -			if (iconv->isAppUTF16())
    -			{
    -				if (srcLength != SQL_NTS)
    -					srcLength = srcLength/2;
    -				// translate from UTF16
    -				if (iconv->WCharToUTF8((UChar*)srcDataPtr, srcLength, srcDataLocale, sizeof(srcDataLocale), (int*)&translateLength, (char*)errorMsg) != SQL_SUCCESS)
    -					return IDS_193_DRVTODS_ERROR;
    -				srcDataPtr = srcDataLocale;
    -				srcLength = translateLength;
    -			}
    -		case SQL_C_CHAR:
    -			if (srcLength == SQL_NTS)
    -				tempLen = strlen((const char *)srcDataPtr);
    -			else
    -				tempLen = srcLength;
    -
    -			if( tempLen > sizeof( cTmpBuf ) - 1)
    -				return IDS_22_003;
    -
    -			strncpy(cTmpBuf,(char*)srcDataPtr, tempLen);
    -			cTmpBuf[ tempLen ] = '\0';
    -			rTrim(cTmpBuf);
    -			tempLen = strlen(cTmpBuf);
    -
    -			if( ((SQLDataType == SQLTYPECODE_NUMERIC) && (targetPrecision > 18)) ||
    -				((SQLDataType == SQLTYPECODE_NUMERIC_UNSIGNED) && (targetPrecision > 9))) //for bignum support
    -			{ //Bignum
    -
    -				retCode = Ascii_To_Bignum_Helper(cTmpBuf,
    -					tempLen,
    -					(char*)cTmpBuf2,
    -					targetLength,
    -					targetPrecision,
    -					targetScale,
    -					SQLDataType,
    -					&dataTruncatedWarning);
    -
    -				if(retCode != SQL_SUCCESS)
    -					return retCode;
    -
    -				useDouble = FALSE;
    -				if (DataPtr == NULL)
    -//					DataPtr = targetDataPtr;
    -					DataPtr = (char*)cTmpBuf2;
    -
    -				DataLen = targetLength;
    -
    -			} else {
    -				if ((retCode = ConvertCharToInt64Num(cTmpBuf, integralPart,
    -							decimalPart, negative, leadZeros)) != 0)
    -				{
    -// Return values -1 - Out of Range
    -//				 -2 - Illegal numeric value
    -
    -					if (retCode == -1)
    -						return IDS_22_003;
    -					if (retCode == -2)
    -						return IDS_22_005;
    -				}
    -				if(negative && targetUnsigned)
    -					return IDS_22_003_02;
    -				if ((integralPart < 0) || (integralPart > integralMax))
    -					return IDS_22_003;
    -				decimalDigits = 0;
    -				if (decimalPart > 0)
    -					decimalDigits = getDigitCount(decimalPart);
    -				if ((decimalPart > decimalMax) || ((decimalDigits + leadZeros) > targetScale))
    -				{
    -					retCode = IDS_01_S07;
    -					// sol 10-080603-3635
    -					// trim the decimalPart based one the scale
    -					// the number of digits in the decimal portion needs to be adjusted if it contain
    -					// leading zero(s)
    -					decimalPart=decimalPart/pow((double)10, (int)(getDigitCount(decimalPart) + leadZeros - targetScale));
    -				}
    -				useDouble = FALSE;
    -			}
    -			break;
    -		case SQL_C_NUMERIC:
    -			ConvertCNumericToChar((SQL_NUMERIC_STRUCT*)srcDataPtr, cTmpBuf);
    -			tempLen = strlen(cTmpBuf);
    -			if (((SQLDataType == SQLTYPECODE_NUMERIC) && (targetPrecision > 18)) ||
    -				((SQLDataType == SQLTYPECODE_NUMERIC_UNSIGNED) && (targetPrecision > 9))) //for bignum support
    -			{ //Bignum
    -
    -				retCode = Ascii_To_Bignum_Helper(cTmpBuf,
    -					tempLen,
    -					(char*)targetDataPtr,
    -					targetLength,
    -					targetPrecision,
    -					targetScale,
    -					SQLDataType,
    -					&dataTruncatedWarning);
    -
    -				if(retCode != SQL_SUCCESS)
    -					return retCode;
    -
    -				useDouble = FALSE;
    -				if (DataPtr == NULL)
    -					DataPtr = targetDataPtr;
    -
    -				DataLen = targetLength;
    -			}
    -			else {
    -				if ((retCode = ConvertCharToInt64Num(cTmpBuf, integralPart,
    -							decimalPart, negative, leadZeros)) != 0)
    -				{
    -// Return values -1 - Out of Range
    -//				 -2 - Illegal numeric value
    -
    -					if (retCode == -1)
    -						return IDS_22_003;
    -					if (retCode == -2)
    -						return IDS_22_005;
    -				}
    -					if(negative && targetUnsigned)
    -						return IDS_22_003_02;
    -				if ((integralPart < 0) || (integralPart > integralMax))
    -					return IDS_22_003;
    -				decimalDigits = 0;
    -				if (decimalPart > 0)
    -					decimalDigits = getDigitCount(decimalPart);
    -				if ((decimalPart > decimalMax) || ((decimalDigits + leadZeros) > targetScale))
    -				{
    -					retCode = IDS_01_S07;
    -					// sol 10-080603-3635
    -					// trim the decimalPart based one the scale
    -					// the number of digits in the decimal portion needs to be adjusted if it contain
    -					// leading zero(s)
    -					decimalPart=decimalPart/pow((double)10, (int)(getDigitCount(decimalPart) + leadZeros - targetScale));
    -				}
    -				useDouble = FALSE;
    -			}
    -
    -			break;
    -
    -		case SQL_C_FLOAT:
    -		case SQL_C_DOUBLE:
    -			if(CDataType == SQL_C_DOUBLE)
    -				dTmp = *(DOUBLE *)srcDataPtr;
    -			else
    -				dTmp = *(SFLOAT *)srcDataPtr;
    -			negative = (dTmp < 0)? 1: 0;
    -			if( ((SQLDataType == SQLTYPECODE_NUMERIC) && (targetPrecision > 18)) ||
    -				((SQLDataType == SQLTYPECODE_NUMERIC_UNSIGNED) && (targetPrecision > 9)))
    -			{ //Bignum
    -
    -				if(CDataType == SQL_C_DOUBLE)
    -				{
    -					if (!double_to_char (dTmp, DBL_DIG, cTmpBuf, sizeof(cTmpBuf)))
    -						dataTruncatedWarning = TRUE;
    -				}
    -				else
    -				{
    -					if (!double_to_char (dTmp, FLT_DIG, cTmpBuf, sizeof(cTmpBuf)))
    -						dataTruncatedWarning = TRUE;
    -				}
     
    +                case SQL_INTEGER:
    +                    if (targetUnsigned)
    +                    {
    +                        if (dTmp < 0)
    +                            return IDS_22_003_02;//negValue in unsigned col error
    +                        if (dTmp > UINT_MAX )
    +                            return IDS_22_003;
    +                        ulTmp = (ULONG_P)dTmp;
    +                        if  (dTmp != ulTmp)
    +                            retCode = IDS_01_S07;
    +                        DataPtr = &ulTmp;
    +                        DataLen = sizeof(ULONG_P);
    +                    }
    +                    else
    +                    {
    +                        if (!signedInteger)
    +                        {
    +                            if (dTmp < 0 || dTmp > UINT_MAX )
    +                                return IDS_22_003;
    +                            lTmp = (SLONG_P)dTmp;
    +                        }
    +                        else
    +                        {
    +                            if (dTmp < INT_MIN || dTmp > INT_MAX)
    +                                return IDS_22_003;
    +                            lTmp = (SLONG_P)dTmp;
    +                            if  (dTmp != lTmp)
    +                                retCode = IDS_01_S07;
    +                        }
    +                        DataPtr = &lTmp;
    +                        DataLen = sizeof(SLONG_P);                    }
    +                    break;
     
    -				retCode = Ascii_To_Bignum_Helper(cTmpBuf,
    -					strlen(cTmpBuf),
    -					(char*)cTmpBuf2,
    -					targetLength,
    -					targetPrecision,
    -					targetScale,
    -					SQLDataType,
    -					&dataTruncatedWarning);
    +                case SQL_REAL:
    +                    if (dTmp < -FLT_MAX || dTmp > FLT_MAX)
    +                        return IDS_22_003;
    +                    fltTmp = (SFLOAT)dTmp;
    +                    DataPtr = &fltTmp;
    +                    DataLen = sizeof(fltTmp);
    +                    break;
     
    -				if(retCode != SQL_SUCCESS)
    -					return retCode;
    +                case SQL_DOUBLE:
    +                case SQL_FLOAT:
    +                    DataPtr = &dTmp;
    +                    DataLen = sizeof(dTmp);
    +                    break;
     
    -				useDouble = FALSE;
    -				if (DataPtr == NULL)
    -					DataPtr = cTmpBuf2;
    +                case SQL_DECIMAL:
    +                    if (targetPrecision >= sizeof(cTmpBuf))
    +                        return IDS_22_003;
    +#if defined MXHPUX || defined MXOSS || defined MXAIX || MXSUNSPARC || MXSUNSPARC
    +                    dTmp1 = pow((double)10,targetPrecision-targetScale+1);
    +#else
    +                    dTmp1 = pow(10,targetPrecision-targetScale+1);
    +#endif
    +                    if (targetUnsigned)
    +                    {
    +                        if (dTmp < 0)
    +                            return IDS_22_003_02;  //negValue in unsigned column
    +                        if (dTmp > dTmp1)
    +                            return IDS_22_003;
     
    -				DataLen = targetLength;
    -				memcpy(outDataPtr, DataPtr, DataLen);
    -				if (byteSwap)
    -				{
    -					if (Datatype_Dependent_Swap((BYTE *)outDataPtr, SQLDataType, targetCharSet, DataLen, IEEE_TO_TANDEM) != STATUS_OK)
    -						return IDS_HY_000;
    -				}
    +                        tempPtr = _fcvt(dTmp, targetScale, &dec, &sign);
    +                        tempLen = strlen(tempPtr);
    +                        tempLen1 = (short)(targetPrecision-tempLen);
     
    -				if(dataTruncatedWarning)
    -					return IDS_01_S07;
    -				else
    -					return SQL_SUCCESS;
    +                        if (tempLen1 < 0)
    +                            return IDS_22_003;
     
    -			}
    -			break;
    +                        memset((void *)cTmpBuf, '0', tempLen1);
    +                        strncpy((char *)(cTmpBuf+tempLen1), tempPtr, tempLen);
    +                    }
    +                    else
    +                    {
    +                        if (dTmp < -dTmp1 || dTmp > dTmp1)
    +                            return IDS_22_003;
     
    -		case SQL_C_SHORT:
    -		case SQL_C_SSHORT:
    -			dTmp = *(SSHORT *)srcDataPtr;
    -			break;
    -		case SQL_C_TINYINT:
    -		case SQL_C_STINYINT:
    -			dTmp = *(SCHAR *)srcDataPtr;
    -			break;
    -		case SQL_C_SLONG:
    -		case SQL_C_LONG:
    -			dTmp = *(SLONG_P *)srcDataPtr;
    -			break;
    -		case SQL_C_USHORT:
    -			dTmp = *(USHORT *)srcDataPtr;
    -			break;
    -		case SQL_C_UTINYINT:
    -		case SQL_C_BIT:
    -			dTmp = *(UCHAR *)srcDataPtr;
    -			break;
    -		case SQL_C_ULONG:
    -			dTmp = *(ULONG_P *)srcDataPtr;
    -			break;
    -		case SQL_C_BINARY:
    -			if (srcLength != OutLen)
    -				return IDS_22_003;
    -			DataPtr = srcDataPtr;
    -			DataLen = OutLen;
    -			break;
    -		case SQL_C_SBIGINT:
    -			integralPart = *(__int64*)srcDataPtr;
    +                        tempPtr = _fcvt(dTmp, targetScale, &dec, &sign);
    +                        tempLen = strlen(tempPtr);
    +                        tempLen1 = (short)(targetPrecision-tempLen);
     
    -			negative = (integralPart < 0)? 1: 0;
    -			integralPart = (integralPart < 0)? -integralPart: integralPart;
    -			decimalPart = 0;
    -			leadZeros = 0;
    -			if ( integralPart > integralMax )
    -				return IDS_22_003;
    +                        if (tempLen1 < 0)
    +                            return IDS_22_003;
     
    -			useDouble = FALSE;
    -			break;
    -		case SQL_C_INTERVAL_MONTH:
    -			intervalTmp = (SQL_INTERVAL_STRUCT *)srcDataPtr;
    -			if (intervalTmp->interval_sign == SQL_TRUE)
    -				dTmp = -(intervalTmp->intval.year_month.month);
    -			else
    -				dTmp = intervalTmp->intval.year_month.month;
    -			break;
    -		case SQL_C_INTERVAL_YEAR:
    -			intervalTmp = (SQL_INTERVAL_STRUCT *)srcDataPtr;
    -			if (intervalTmp->interval_sign == SQL_TRUE)
    -				dTmp = -(intervalTmp->intval.year_month.year);
    -			else
    -				dTmp = intervalTmp->intval.year_month.year;
    -			break;
    -		case SQL_C_INTERVAL_DAY:
    -			intervalTmp = (SQL_INTERVAL_STRUCT *)srcDataPtr;
    -			if (intervalTmp->interval_sign == SQL_TRUE)
    -				dTmp = -(intervalTmp->intval.day_second.day);
    -			else
    -				dTmp = intervalTmp->intval.day_second.day;
    -			break;
    -		case SQL_C_INTERVAL_HOUR:
    -			intervalTmp = (SQL_INTERVAL_STRUCT *)srcDataPtr;
    -			if (intervalTmp->interval_sign == SQL_TRUE)
    -				dTmp = -(intervalTmp->intval.day_second.hour);
    -			else
    -				dTmp = intervalTmp->intval.day_second.hour;
    -			break;
    -		case SQL_C_INTERVAL_MINUTE:
    -			intervalTmp = (SQL_INTERVAL_STRUCT *)srcDataPtr;
    -			if (intervalTmp->interval_sign == SQL_TRUE)
    -				dTmp = -(intervalTmp->intval.day_second.minute);
    -			else
    -				dTmp = intervalTmp->intval.day_second.minute;
    -			break;
    -		case SQL_C_INTERVAL_SECOND:
    -			intervalTmp = (SQL_INTERVAL_STRUCT *)srcDataPtr;
    -			if (intervalTmp->interval_sign == SQL_TRUE)
    -				dTmp = -(intervalTmp->intval.day_second.second);
    -			else
    -				dTmp = intervalTmp->intval.day_second.second;
    -			break;
    -		default:
    -			return IDS_07_006;
    -		}
    -		if (DataPtr == NULL)
    -		{
    -			if (useDouble)
    -			{
    -				if( targetUnsigned && ( dTmp < 0 || negative ))
    -					return IDS_22_003_02;	//negValue in unsigned column
    -
    -				dTmp1 = pow((double)10, targetPrecision-targetScale+1);
    -				if (dTmp < -dTmp1 || dTmp > dTmp1)
    -					return IDS_22_003;
    -				scaleOffset = pow(10, targetScale);		// This value always multplied to srcValue
    -											// since SQL stores it as a implied decimal point
    -											// 1.0 for NUMERIC (4,2) value is stored as 100
    -				dTmp *= scaleOffset;
    -				switch (SQLDataType)
    -				{
    -                case SQLTYPECODE_BOOLEAN:
    -                    tTmp = (SCHAR)dTmp;
    -                    DataPtr = &tTmp;
    -                    DataLen = sizeof(SCHAR);
    +                        memset((void *)cTmpBuf, '0', tempLen1);
    +                        strncpy((char *)(cTmpBuf+tempLen1), tempPtr, tempLen);
    +                        if (sign)
    +                            *cTmpBuf = (UCHAR)(*cTmpBuf | (UCHAR)0x80);
    +                    }
    +                    DataPtr = cTmpBuf;
    +                    DataLen = targetPrecision;
                         break;
    +                default:
    +                    return IDS_07_006;
    +            }
    +        }
    +        else
    +        {
    +            if (targetScale)
    +            {
    +                for (i = 0,tempVal64 = 1; i < targetScale ;  i++)
    +                    tempVal64 *= 10;
    +                tempVal64 = tempVal64 * integralPart;
    +                decimalDigits = 0;
    +                if (decimalPart > 0)
    +                    decimalDigits = getDigitCount(decimalPart);
    +                scaleOffset = 0;
    +                if (leadZeros < targetScale)
    +                    scaleOffset = targetScale - decimalDigits - leadZeros;
    +                if (scaleOffset < 0)
    +                {
    +                    //NUMERIC_VALUE_OUT_OF_RANGE_ERROR
    +                    return IDS_22_003;
    +                }
    +                for (i =0, tempScaleVal64 = decimalPart ; i < scaleOffset ; i++)
    +                    tempScaleVal64 *= 10;
    +                tempVal64 += tempScaleVal64;
    +            }
    +            else
    +            {
    +                //NUMERIC_DATA_TRUNCATED_ERROR
    +                if (decimalPart != 0)
    +                    retCode = IDS_01_S07;
    +                tempVal64 = integralPart;
    +            }
    +            if (negative)
    +                tempVal64 = -tempVal64;
    +
    +            switch( SQLDataType )
    +            {
                     case SQLTYPECODE_TINYINT_UNSIGNED:
    -                    utTmp = (UCHAR)dTmp;
    +                    if (tempVal64 < 0)
    +                        return IDS_22_003_02;
    +                    if (tempVal64 > UCHAR_MAX)
    +                        return IDS_22_003;
    +                    utTmp = (UCHAR)tempVal64;
    +                    if  (tempVal64 != utTmp)
    +                        retCode = IDS_01_S07;
                         DataPtr = &utTmp;
                         DataLen = sizeof(UCHAR);
                         break;
                     case SQLTYPECODE_TINYINT:
    -                    tTmp = (SCHAR)dTmp;
    +                    if (tempVal64 < SCHAR_MIN || tempVal64 > SCHAR_MAX)
    +                        return IDS_22_003;
    +                    tTmp = (SCHAR)tempVal64;
    +                    if  (tempVal64 != tTmp)
    +                        retCode = IDS_01_S07;
                         DataPtr = &tTmp;
                         DataLen = sizeof(SCHAR);
                         break;
    -				case SQLTYPECODE_SMALLINT_UNSIGNED:
    -					usTmp = (USHORT)dTmp;
    -					DataPtr = &usTmp;
    -					DataLen = sizeof(usTmp);
    -					break;
    -				case SQLTYPECODE_SMALLINT:
    -					sTmp = (SHORT)dTmp;
    -					DataPtr = &sTmp;
    -					DataLen = sizeof(sTmp);
    -					break;
    -				case SQLTYPECODE_INTEGER_UNSIGNED:
    -					ulTmp = (ULONG_P)dTmp;
    -					DataPtr = &ulTmp;
    -					DataLen = sizeof(ulTmp);
    -					break;
    -				case SQLTYPECODE_INTEGER:
    -					lTmp = (LONG)dTmp;
    -					DataPtr = &lTmp;
    -					DataLen = sizeof(lTmp);
    -					break;
    -				case SQLTYPECODE_LARGEINT:
    -					tempVal64 = (__int64)dTmp;
    -					DataPtr = &tempVal64;
    -					DataLen = sizeof(tempVal64);
    -					break;
    -				default:
    -					return IDS_07_006;
    -				}
    -			}
    -			else
    -			{
    -				if( targetUnsigned && negative )
    -					return IDS_22_003_02;	//negValue in unsigned column
    -
    -				if (targetScale)
    -				{
    -					for (i = 0,tempVal64 = 1; i < targetScale ;  i++)
    -						tempVal64 *= 10;
    -					tempVal64 = tempVal64 * integralPart;
    -					decimalDigits = 0;
    -					if (decimalPart > 0)
    -						decimalDigits = getDigitCount(decimalPart);
    -					scaleOffset = 0;
    -					if (leadZeros < targetScale)
    -					  scaleOffset = targetScale - decimalDigits - leadZeros;
    -					if (scaleOffset < 0)
    -					{
    -//NUMERIC_VALUE_OUT_OF_RANGE_ERROR
    -						return IDS_22_003;
    -					}
    -
    -					for (i =0, tempScaleVal64 = decimalPart ; i < scaleOffset ; i++)
    -						tempScaleVal64 *= 10;
    -					tempVal64 += tempScaleVal64;
    -				}
    -				else
    -				{
    -//NUMERIC_DATA_TRUNCATED_ERROR
    -					if (decimalPart != 0)
    -						retCode = IDS_01_S07;
    -					tempVal64 = integralPart;
    -				}
    -				if (negative)
    -					tempVal64 = -tempVal64;
    -
    -				switch( SQLDataType )
    -				{
    -				case SQLTYPECODE_SMALLINT_UNSIGNED:
    -					if (tempVal64 < 0)
    -					       return IDS_22_003_02;
    -					if ((USHORT)tempVal64 > USHRT_MAX)
    -						return IDS_22_003;
    -					usTmp = (USHORT)tempVal64;
    -					if  (tempVal64 != usTmp)
    -						retCode = IDS_01_S07;
    -					DataPtr = &usTmp;
    -					DataLen = sizeof(USHORT);
    -					break;
    -				case SQLTYPECODE_SMALLINT:
    -					if (tempVal64 < SHRT_MIN || tempVal64 > SHRT_MAX)
    -						return IDS_22_003;
    -					sTmp = (SHORT)tempVal64;
    -					if  (tempVal64 != sTmp)
    -						retCode = IDS_01_S07;
    -					DataPtr = &sTmp;
    -					DataLen = sizeof(sTmp);
    -					break;
    -				case SQLTYPECODE_INTEGER_UNSIGNED:
    -					// solution 10-080804-4996
    -					// for 64 bit Solaris/AIX (with XlC cplr),
    -					// tempVal64 is a signed LONG LONG,
    -					// ULONG_MAX is unsigned LONG of 'FFFFFFF....',
    -					// somehow it will evaluate tempVal64 GT ULONG_MAX
    -					// so cast the tempVal64 to (ULONG)
    -					if (tempVal64 < 0)
    -					       return IDS_22_003_02;
    -					if ((ULONG_P)tempVal64 > ULONG_MAX)
    -						return IDS_22_003;
    -					ulTmp = (ULONG_P)tempVal64;
    -					if  (tempVal64 != ulTmp)
    -						retCode = IDS_01_S07;
    -					DataPtr = &ulTmp;
    -					DataLen = sizeof(ulTmp);
    -					break;
    -				case SQLTYPECODE_INTEGER:
    -					if (tempVal64 < LONG_MIN || tempVal64 > LONG_MAX)
    -						return IDS_22_003;
    -					lTmp = (LONG)tempVal64;
    -					if  (tempVal64 != lTmp)
    -						retCode = IDS_01_S07;
    -					DataPtr = &lTmp;
    -					DataLen = sizeof(lTmp);
    -					break;
    -				case SQLTYPECODE_LARGEINT:
    -				default:
    -					DataPtr = &tempVal64;
    -					DataLen = sizeof(tempVal64);
    -					break;
    -				}
     
    +                case SQLTYPECODE_SMALLINT_UNSIGNED:
    +                    if (tempVal64 < 0)
    +                        return IDS_22_003_02;
    +                    if ((USHORT)tempVal64 > USHRT_MAX)
    +                        return IDS_22_003;
    +                    usTmp = (USHORT)tempVal64;
    +                    if  (tempVal64 != usTmp)
    +                        retCode = IDS_01_S07;
    +                    DataPtr = &usTmp;
    +                    DataLen = sizeof(USHORT);
    +                    break;
    +                case SQLTYPECODE_SMALLINT:
    +                    if (tempVal64 < SHRT_MIN || tempVal64 > SHRT_MAX)
    +                        return IDS_22_003;
    +                    sTmp = (SHORT)tempVal64;
    +                    if  (tempVal64 != sTmp)
    +                        retCode = IDS_01_S07;
    +                    DataPtr = &sTmp;
    +                    DataLen = sizeof(SHORT);
    +                    break;
     
    -			}
    +                case SQLTYPECODE_INTEGER_UNSIGNED:
    +                    if (tempVal64 < 0)
    +                        return IDS_22_003_02;
    +                    if ((ULONG_P)tempVal64 > ULONG_MAX)
    +                        return IDS_22_003;
    +                    ulTmp = (ULONG_P)tempVal64;
    +                    if  (tempVal64 != ulTmp)
    +                        retCode = IDS_01_S07;
    +                    DataPtr = &ulTmp;
    +                    DataLen = sizeof(ULONG_P);
    +                    break;
    +                case SQLTYPECODE_INTEGER:
    +                    if (tempVal64 < LONG_MIN || tempVal64 > LONG_MAX)
    +                        return IDS_22_003;
    +                    lTmp = (LONG)tempVal64;
    +                    if  (tempVal64 != lTmp)
    +                        retCode = IDS_01_S07;
    +                    DataPtr = &lTmp;
    +                    DataLen = sizeof(LONG);
    +                    break;
     
    +                case SQLTYPECODE_IEEE_FLOAT:
    +                    if (tempVal64 < -FLT_MAX || tempVal64 > FLT_MAX)
    +                        return IDS_22_003;
    +                    fltTmp = (FLOAT)tempVal64;
    +                    if  (tempVal64 != fltTmp)
    +                        retCode = IDS_01_S07;
    +                    DataPtr = &fltTmp;
    +                    DataLen = sizeof(FLOAT);
    +                    break;
    +                case SQLTYPECODE_IEEE_DOUBLE:
    +                    if (tempVal64 < -DBL_MAX || tempVal64 > DBL_MAX)
    +                        return IDS_22_003;
    +                    dTmp = (DOUBLE)tempVal64;
    +                    if  (tempVal64 != dTmp)
    +                        retCode = IDS_01_S07;
    +                    DataPtr = &dTmp;
    +                    DataLen = sizeof(DOUBLE);
    +                    break;
     
    -		}
    -		break; // End of case for SQL_NUMERIC
    -	case SQL_DATE:
    -	case SQL_TYPE_DATE:
    -		switch (CDataType)
    -		{
    -		case SQL_C_WCHAR:
    -			if (iconv->isAppUTF16())
    -			{
    -				if (srcLength != SQL_NTS)
    -					srcLength = srcLength/2;
    -				// translate from UTF16
    -				if (iconv->WCharToUTF8((UChar*)srcDataPtr, srcLength, srcDataLocale, sizeof(srcDataLocale), (int*)&translateLength, (char*)errorMsg) != SQL_SUCCESS)
    -					return IDS_193_DRVTODS_ERROR;
    -				srcDataPtr = srcDataLocale;
    -				srcLength = translateLength;
    -			}
    -		case SQL_C_CHAR:
    -			if (ConvertCharToSQLDate(srcDataPtr, srcLength, ODBCDataType, &SQLDate, targetPrecision)
    -					!= SQL_SUCCESS)
    -				return IDS_22_008;
    -			break;
    -		case SQL_C_DATE:
    -		case SQL_C_TYPE_DATE:
    -		case SQL_C_DEFAULT:
    -			dateTmp = (DATE_STRUCT *)srcDataPtr;
    -
    -			for (i = 0 ; i < 8 ; i++)
    -				datetime_parts[i] = 0;
    -			datetime_parts[0] = dateTmp->year;
    -			datetime_parts[1] = dateTmp->month;
    -			datetime_parts[2] = dateTmp->day;
    -			if (!checkDatetimeValue(datetime_parts))
    -				return IDS_22_008;
    -
    -			SQLDate.year = dateTmp->year;
    -			SQLDate.month = dateTmp->month;
    -			SQLDate.day = dateTmp->day;
    -			break;
    -		case SQL_C_TIMESTAMP:
    -		case SQL_C_TYPE_TIMESTAMP:
    -			timestampTmp = (TIMESTAMP_STRUCT *)srcDataPtr;
    -// SQL/MX fraction precision is max 6 digits but ODBC accepts max precision 9 digits
    -// conversion from nano to micro fraction of second
    -			ulFraction = (UDWORD_P)timestampTmp->fraction;
    -			if (targetPrecision > 0)
    -			{
    -				ulFraction /= 1000;
    -				sprintf(cTmpBuf, "%06u", ulFraction);
    -				cTmpBuf[targetPrecision] = 0;
    -				strcpy(cTmpFraction,cTmpBuf);
    -			}
    +                case SQLTYPECODE_DECIMAL_UNSIGNED:
    +                case SQLTYPECODE_DECIMAL_LARGE_UNSIGNED: // Tandem extension
    +                    if(negative)
    +                        return IDS_22_003_02;
    +                case SQLTYPECODE_DECIMAL:
    +                case SQLTYPECODE_DECIMAL_LARGE: // Tandem extension
    +                    if(negative)
    +                        tempVal64 = -tempVal64;
    +#if defined MXHPUX || defined MXOSS || defined MXAIX || MXSUNSPARC || MXSUNSPARC
    +                    sprintf(cTmpBuf, "%0*lld", targetPrecision, tempVal64);
    +#elif defined unixcli
    +                    sprintf(cTmpBuf, "%0*Ld", targetPrecision, tempVal64);
    +#else
    +                    sprintf(cTmpBuf, "%0*I64d", targetPrecision, tempVal64);
    +#endif
    +                    if (negative)
    +                        *cTmpBuf = (UCHAR)(*cTmpBuf | (UCHAR)0x80);
    +                    DataPtr = cTmpBuf;
    +                    DataLen = strlen(cTmpBuf);
    +                    break;
     
    -			for (i = 0 ; i < 8 ; i++)
    -				datetime_parts[i] = 0;
    -			datetime_parts[0] = timestampTmp->year;
    -			datetime_parts[1] = timestampTmp->month;
    -			datetime_parts[2] = timestampTmp->day;
    -			datetime_parts[3] = timestampTmp->hour;
    -			datetime_parts[4] = timestampTmp->minute;
    -			datetime_parts[5] = timestampTmp->second;
    -			datetime_parts[6] = (short)(ulFraction/1000);
    -			datetime_parts[7] = (short)(ulFraction%1000);
    -			if (!checkDatetimeValue(datetime_parts))
    -				return IDS_22_008;
    -
    -			SQLDate.year = timestampTmp->year;
    -			SQLDate.month = timestampTmp->month;
    -			SQLDate.day = timestampTmp->day;
    -/*
    -			if (timestampTmp->hour != 0 || timestampTmp->minute != 0 || timestampTmp->second != 0 ||
    -				timestampTmp->fraction != 0)
    -			{
    -				if (ODBCAppVersion >= SQL_OV_ODBC3)
    -					return IDS_22_008;
    -				else
    -					retCode = IDS_22_001;
    -			}
    -*/
    -			break;
    -		case SQL_C_BINARY:
    -			if (srcLength != targetLength)
    -				return IDS_22_003;
    -			DataPtr = srcDataPtr;
    -			break;
    -		default:
    -			return IDS_07_006;
    -		}
    -		if (DataPtr == NULL)
    -			DataPtr = &SQLDate;
    -		DataLen = targetLength;
    +               case SQLTYPECODE_LARGEINT_UNSIGNED:
    +                    if(tempVal64<0)
    +                        return IDS_22_003_02;
    +                    if((unsigned __int64)tempVal64 > ULLONG_MAX)
    +                        return IDS_22_003;
    +                    uVal64 = (unsigned __int64)tempVal64;
    +                    if(tempVal64 != uVal64)
    +                        retCode = IDS_01_S07;
    +                    DataPtr = &uVal64;
    +                    DataLen = sizeof(unsigned __int64);
    +                    break;
    +               case SQLTYPECODE_LARGEINT:
    +                    DataPtr = &tempVal64;
    +                    DataLen = sizeof(__int64);
    +                    break;
     
    -		if (CDataType != SQL_C_BINARY && RWRSFormat == 0)
    -		{
    -			pSQLDate = (DATE_TYPES*)DataPtr;
    -			switch (SQLDatetimeCode)
    -			{
    -			case SQLDTCODE_YEAR:
    -				DataLen = sprintf(cTmpBuf, "%04d", pSQLDate->year);
    -				break;
    -			case SQLDTCODE_YEAR_TO_MONTH:
    -				DataLen = sprintf(cTmpBuf, "%04d-%02d", pSQLDate->year,pSQLDate->month);
    -				break;
    -			case SQLDTCODE_MONTH:
    -				DataLen = sprintf(cTmpBuf, "%02d", pSQLDate->month);
    -				break;
    -			case SQLDTCODE_MONTH_TO_DAY:
    -				DataLen = sprintf(cTmpBuf, "%02d-%02d", pSQLDate->month,pSQLDate->day);
    -				break;
    -			case SQLDTCODE_DAY:
    -				DataLen = sprintf(cTmpBuf, "%02d", pSQLDate->day);
    -				break;
    -			default:
    -				DataLen = sprintf(cTmpBuf, "%04d-%02d-%02d", pSQLDate->year,pSQLDate->month,pSQLDate->day);
    -			}
    -			DataPtr = cTmpBuf;
    -		}
    -		if (DataLen != targetLength)
    -			return IDS_22_003;
    -		break; // End of case for SQL_DATE
    -	case SQL_TIME:
    -	case SQL_TYPE_TIME:
    -		switch (CDataType)
    -		{
    -		case SQL_C_WCHAR:
    -			if (iconv->isAppUTF16())
    -			{
    -				if (srcLength != SQL_NTS)
    -					srcLength = srcLength/2;
    -				// translate from UTF16 to
    -				if (iconv->WCharToUTF8((UChar*)srcDataPtr, srcLength, srcDataLocale, sizeof(srcDataLocale), (int*)&translateLength, (char*)errorMsg) != SQL_SUCCESS)
    -					return IDS_193_DRVTODS_ERROR;
    -				srcDataPtr = srcDataLocale;
    -				srcLength = translateLength;
    -			}
    -		case SQL_C_CHAR:
    -			if (ConvertCharToSQLDate(srcDataPtr, srcLength, ODBCDataType, &SQLTime, targetPrecision)
    -					!= SQL_SUCCESS)
    -				return IDS_22_008;
    -			break;
    -		case SQL_C_TIME:
    -		case SQL_C_TYPE_TIME:
    -		case SQL_C_DEFAULT:
    -			timeTmp = (TIME_STRUCT *)srcDataPtr;
    -
    -			for (i = 0 ; i < 8 ; i++)
    -				datetime_parts[i] = 0;
    -			datetime_parts[0] = 1;
    -			datetime_parts[1] = 1;
    -			datetime_parts[2] = 1;
    -			datetime_parts[3] = timeTmp->hour;
    -			datetime_parts[4] = timeTmp->minute;
    -			datetime_parts[5] = timeTmp->second;
    -			if (!checkDatetimeValue(datetime_parts))
    -				return IDS_22_008;
    -
    -			SQLTime.hour = timeTmp->hour;
    -			SQLTime.minute = timeTmp->minute;
    -			SQLTime.second = timeTmp->second;
    -			memset(&SQLTime.fraction,0,sizeof(UDWORD_P));
    -			break;
    -		case SQL_C_TIMESTAMP:
    -		case SQL_C_TYPE_TIMESTAMP:
    -			timestampTmp = (TIMESTAMP_STRUCT *)srcDataPtr;
    -// SQL/MX fraction precision is max 6 digits but ODBC accepts max precision 9 digits
    -// conversion from nano to micro fraction of second
    -			ulFraction = (UDWORD_P)timestampTmp->fraction;
    -			if (targetPrecision > 0)
    -			{
    -				ulFraction /= 1000;
    -				sprintf(cTmpBuf, "%06u", ulFraction);
    -				cTmpBuf[targetPrecision] = 0;
    -				strcpy(cTmpFraction,cTmpBuf);
    -			}
    +               default:
    +                    return IDS_07_006;
    +            }
    +        }
    +    }
    +    else
    +    {
    +        switch (ODBCDataType)
    +        {
    +            case SQL_TINYINT:
    +                DataLen = sizeof(SCHAR);
    +                break;
    +            case SQL_SMALLINT:
    +                DataLen = sizeof(SHORT);
    +                break;
    +            case SQL_INTEGER:
    +                DataLen = sizeof(LONG);
    +                break;
    +            case SQL_REAL:
    +                DataLen = sizeof(FLOAT);
    +                break;
    +            case SQL_DOUBLE:
    +            case SQL_FLOAT:
    +                DataLen = sizeof(DOUBLE);
    +                break;
    +            default:
    +                return IDS_07_006;
    +        }
    +    }
     
    -			for (i = 0 ; i < 8 ; i++)
    -				datetime_parts[i] = 0;
    -			datetime_parts[0] = timestampTmp->year;
    -			datetime_parts[1] = timestampTmp->month;
    -			datetime_parts[2] = timestampTmp->day;
    -			datetime_parts[3] = timestampTmp->hour;
    -			datetime_parts[4] = timestampTmp->minute;
    -			datetime_parts[5] = timestampTmp->second;
    -			datetime_parts[6] = (short)(ulFraction/1000);
    -			datetime_parts[7] = (short)(ulFraction%1000);
    -			if (!checkDatetimeValue(datetime_parts))
    -				return IDS_22_008;
    -
    -			SQLTime.hour = timestampTmp->hour;
    -			SQLTime.minute = timestampTmp->minute;
    -			SQLTime.second = timestampTmp->second;
    -			memcpy(&SQLTime.fraction, &ulFraction, sizeof(UDWORD_P));
    -			if (targetPrecision == 0 && ulFraction != 0)
    -			{
    -				if (ODBCAppVersion >= SQL_OV_ODBC3)
    -						return IDS_22_008;
    -				else
    -					retCode = IDS_01_S07;
    -			}
    -			break;
    -		case SQL_C_BINARY:
    -			if (srcLength != targetLength)
    -				return IDS_22_008;
    -			DataPtr = srcDataPtr;
    -			break;
    -		default:
    -			return IDS_07_006;
    -			break;
    -		}
    -		if (DataPtr == NULL)
    -			DataPtr = &SQLTime;
    -		DataLen = targetLength;
    +    if(targetLength < DataLen)
    +        return IDS_22_001 ;
    +    memcpy(outDataPtr,DataPtr, DataLen);
    +    return retCode; 
    +}
     
    -		if (CDataType != SQL_C_BINARY && RWRSFormat == 0)
    -		{
    -			pSQLTime = (TIME_TYPES*)DataPtr;
    -			switch  (SQLDatetimeCode)
    -			{
    -			case SQLDTCODE_HOUR:
    -				DataLen = sprintf(cTmpBuf,"%02d",pSQLTime->hour);
    -				break;
    -			case SQLDTCODE_HOUR_TO_MINUTE:
    -				DataLen = sprintf(cTmpBuf,"%02d:%02d",pSQLTime->hour,pSQLTime->minute);
    -				break;
    -			case SQLDTCODE_MINUTE:
    -				DataLen = sprintf(cTmpBuf,"%02d",pSQLTime->minute);
    -				break;
    -			case SQLDTCODE_MINUTE_TO_SECOND:
    -				if (targetPrecision > 0)
    -					DataLen = sprintf(cTmpBuf,"%02d:%02d.%s",pSQLTime->minute,pSQLTime->second,cTmpFraction);
    -				else
    -					DataLen = sprintf(cTmpBuf,"%02d:%02d",pSQLTime->minute,pSQLTime->second);
    -				break;
    -			case SQLDTCODE_SECOND:
    -				DataLen = sprintf(cTmpBuf,"%02d",pSQLTime->second);
    -				break;
    -			default:
    -				DataLen = sprintf(cTmpBuf,"%02d:%02d:%02d",pSQLTime->hour,pSQLTime->minute,pSQLTime->second);
    -				break;
    -			}
    -			DataPtr = cTmpBuf;
    -		}
    -		if (DataLen != targetLength)
    -			return IDS_22_008;
    -		break; // End of case for SQL_TIME
    -	case SQL_TIMESTAMP:
    -	case SQL_TYPE_TIMESTAMP:
    -		switch (CDataType)
    -		{
    -		case SQL_C_WCHAR:
    -			if (iconv->isAppUTF16())
    -			{
    -				if (srcLength != SQL_NTS)
    -					srcLength = srcLength/2;
    -				// translate from UTF16
    -				if (iconv->WCharToUTF8((UChar*)srcDataPtr, srcLength, srcDataLocale, sizeof(srcDataLocale), (int*)&translateLength, (char*)errorMsg) != SQL_SUCCESS)
    -					return IDS_193_DRVTODS_ERROR;
    -				srcDataPtr = srcDataLocale;
    -				srcLength = translateLength;
    -			}
    -		case SQL_C_CHAR:
    -			if (ConvertCharToSQLDate(srcDataPtr, srcLength, ODBCDataType, &SQLTimestamp, targetPrecision)
    -					!= SQL_SUCCESS)
    -				return IDS_22_008;
    -			memcpy(&ulFraction, &SQLTimestamp.fraction, sizeof(UDWORD_P));
    -			if (targetPrecision > 0)
    -			{
    -				sprintf(cTmpFraction, "%0*lu", targetPrecision, ulFraction);
    -			}
    -			break;
    -		case SQL_C_DATE:
    -		case SQL_C_TYPE_DATE:
    -			dateTmp = (DATE_STRUCT *)srcDataPtr;
    -
    -			for (i = 0 ; i < 8 ; i++)
    -				datetime_parts[i] = 0;
    -			datetime_parts[0] = dateTmp->year;
    -			datetime_parts[1] = dateTmp->month;
    -			datetime_parts[2] = dateTmp->day;
    -			if (!checkDatetimeValue(datetime_parts))
    -				return IDS_22_008;
    -
    -			SQLTimestamp.year = dateTmp->year;
    -			SQLTimestamp.month = dateTmp->month;
    -			SQLTimestamp.day = dateTmp->day;
    -			SQLTimestamp.hour = 0;
    -			SQLTimestamp.minute = 0;
    -			SQLTimestamp.second = 0;
    -			memset(&SQLTimestamp.fraction, 0, sizeof(UDWORD_P));
    -			ulFraction = 0;
    -			if (targetPrecision > 0)
    -			{
    -				sprintf(cTmpBuf, "%06u", ulFraction);
    -				cTmpBuf[targetPrecision] = 0;
    -				strcpy(cTmpFraction,cTmpBuf);
    -//				ulFraction = atol(cTmpBuf);
    -			}
    -			break;
    -		case SQL_C_TIME:
    -		case SQL_C_TYPE_TIME:
    -			struct tm *newtime;
    -			time_t long_time;
    -
    -			time( &long_time );					/* Get time as long integer. */
    -			newtime = localtime( &long_time );	/* Convert to local time. */
    -
    -			timeTmp = (TIME_STRUCT *)srcDataPtr;
    -
    -			for (i = 0 ; i < 8 ; i++)
    -				datetime_parts[i] = 0;
    -			datetime_parts[0] = newtime->tm_year+1900;
    -			datetime_parts[1] = newtime->tm_mon+1;
    -			datetime_parts[2] = newtime->tm_mday;
    -			datetime_parts[3] = timeTmp->hour;
    -			datetime_parts[4] = timeTmp->minute;
    -			datetime_parts[5] = timeTmp->second;
    -			if (!checkDatetimeValue(datetime_parts))
    -				return IDS_22_008;
    -
    -			SQLTimestamp.year = newtime->tm_year+1900;
    -			SQLTimestamp.month = newtime->tm_mon+1;
    -			SQLTimestamp.day = newtime->tm_mday;
    -			SQLTimestamp.hour = timeTmp->hour;
    -			SQLTimestamp.minute = timeTmp->minute;
    -			SQLTimestamp.second = timeTmp->second;
    -			memset(&SQLTimestamp.fraction, 0, sizeof(UDWORD_P));
    -			ulFraction = 0;
    -			if (targetPrecision > 0)
    -			{
    -				sprintf(cTmpBuf, "%06u", ulFraction);
    -				cTmpBuf[targetPrecision] = 0;
    -				strcpy(cTmpFraction,cTmpBuf);
    -//				ulFraction = atol(cTmpBuf);
    -			}
    -			break;
    -		case SQL_C_TIMESTAMP:
    -		case SQL_C_TYPE_TIMESTAMP:
    -		case SQL_C_DEFAULT:
    -			timestampTmp = (TIMESTAMP_STRUCT *)srcDataPtr;
    -// SQL/MX fraction precision is max 6 digits but ODBC accepts max precision 9 digits
    -// conversion from nano seconds to fraction of a second
    -			ulFraction = (UDWORD_P)timestampTmp->fraction;
    -			if (targetPrecision > 0)
    -				ulFraction = (ulFraction * pow(10,targetPrecision)) / 1000000000.0;
    -			else
    -				ulFraction = 0;
    -			sprintf(cTmpBuf, "%06u", ulFraction);
    -            strcpy(cTmpFraction,&cTmpBuf[6 - targetPrecision]);
     
    -			for (i = 0 ; i < 8 ; i++)
    -				datetime_parts[i] = 0;
    -			datetime_parts[0] = timestampTmp->year;
    -			datetime_parts[1] = timestampTmp->month;
    -			datetime_parts[2] = timestampTmp->day;
    -			datetime_parts[3] = timestampTmp->hour;
    -			datetime_parts[4] = timestampTmp->minute;
    -			datetime_parts[5] = timestampTmp->second;
    -			datetime_parts[6] = (short)(ulFraction/1000);
    -			datetime_parts[7] = (short)(ulFraction%1000);
    -			if (!checkDatetimeValue(datetime_parts))
    -				return IDS_22_008;
    -
    -			SQLTimestamp.year = timestampTmp->year;
    -			SQLTimestamp.month = timestampTmp->month;
    -			SQLTimestamp.day = timestampTmp->day;
    -			SQLTimestamp.hour = timestampTmp->hour;
    -			SQLTimestamp.minute = timestampTmp->minute;
    -			SQLTimestamp.second = timestampTmp->second;
    -			memset(&SQLTimestamp.fraction, 0, sizeof(UDWORD_P));
    -			if (targetPrecision > 0)
    -				memcpy(&SQLTimestamp.fraction, &ulFraction, sizeof(SQLUINTEGER));
    -			break;
    -		case SQL_C_BINARY:
    -			if (srcLength != targetLength)
    -				return IDS_22_003;
    -			DataPtr = srcDataPtr;
    -			break;
    -		default:
    -			return IDS_07_006;
    -		}
    -		if (DataPtr == NULL)
    -			DataPtr = &SQLTimestamp;
    -		if(RWRSFormat == 1)
    -			DataLen = sizeof(SQLTimestamp)-1; // since it is only 11 bytes that matters
    -		OutLen = DataLen; // in case user creates a table as datetime year to second,
    -				  // SQL/MX returns OutLen as 7 bytes
    -				  // Non-standard timestamp table year to second.
    -		if (CDataType != SQL_C_BINARY && RWRSFormat == 0)
    -		{
    -			pSQLTimestamp = (TIMESTAMP_TYPES*)DataPtr;
    -			switch  (SQLDatetimeCode)
    -			{
    -			case SQLDTCODE_TIME:
    -				if (targetPrecision > 0)
    -					DataLen = sprintf(cTmpBuf,"%02d:%02d:%02d.%s",
    -								pSQLTimestamp->hour,pSQLTimestamp->minute,pSQLTimestamp->second,
    -								cTmpFraction);
    -				else
    -					DataLen = sprintf(cTmpBuf,"%02d:%02d:%02d",
    -								pSQLTimestamp->hour,pSQLTimestamp->minute,pSQLTimestamp->second);
    -				break;
    -			case SQLDTCODE_YEAR_TO_HOUR:
    -				DataLen = sprintf(cTmpBuf,"%04d-%02d-%02d %02d",
    -								pSQLTimestamp->year,pSQLTimestamp->month,pSQLTimestamp->day,
    -								pSQLTimestamp->hour);
    -				break;
    -			case SQLDTCODE_YEAR_TO_MINUTE:
    -				DataLen = sprintf(cTmpBuf,"%04d-%02d-%02d %02d:%02d",
    -								pSQLTimestamp->year,pSQLTimestamp->month,pSQLTimestamp->day,
    -								pSQLTimestamp->hour,pSQLTimestamp->minute);
    -				break;
    -			case SQLDTCODE_MONTH_TO_HOUR:
    -				DataLen = sprintf(cTmpBuf,"%02d-%02d %02d",
    -								pSQLTimestamp->month,pSQLTimestamp->day,
    -								pSQLTimestamp->hour);
    -				break;
    -			case SQLDTCODE_MONTH_TO_MINUTE:
    -				DataLen = sprintf(cTmpBuf,"%02d-%02d %02d:%02d",
    -								pSQLTimestamp->month,pSQLTimestamp->day,
    -								pSQLTimestamp->hour,pSQLTimestamp->minute);
    -				break;
    -			case SQLDTCODE_MONTH_TO_SECOND:
    -				if (targetPrecision > 0)
    -					DataLen = sprintf(cTmpBuf,"%02d-%02d %02d:%02d:%02d.%s",
    -								pSQLTimestamp->month,pSQLTimestamp->day,
    -								pSQLTimestamp->hour,pSQLTimestamp->minute,pSQLTimestamp->second,
    -								cTmpFraction);
    -				else
    -					DataLen = sprintf(cTmpBuf,"%02d-%02d %02d:%02d:%02d",
    -								pSQLTimestamp->month,pSQLTimestamp->day,
    -								pSQLTimestamp->hour,pSQLTimestamp->minute,pSQLTimestamp->second);
    -				break;
    -			case SQLDTCODE_DAY_TO_HOUR:
    -				DataLen = sprintf(cTmpBuf,"%02d %02d",
    -								pSQLTimestamp->day,
    -								pSQLTimestamp->hour);
    -				break;
    -			case SQLDTCODE_DAY_TO_MINUTE:
    -				DataLen = sprintf(cTmpBuf,"%02d %02d:%02d",
    -								pSQLTimestamp->day,
    -								pSQLTimestamp->hour,pSQLTimestamp->minute);
    -				break;
    -			case SQLDTCODE_DAY_TO_SECOND:
    -				if (targetPrecision > 0)
    -					DataLen = sprintf(cTmpBuf,"%02d %02d:%02d:%02d.%s",
    -								pSQLTimestamp->day,
    -								pSQLTimestamp->hour,pSQLTimestamp->minute,pSQLTimestamp->second,
    -								cTmpFraction);
    -				else
    -					DataLen = sprintf(cTmpBuf,"%02d %02d:%02d:%02d",
    -								pSQLTimestamp->day,
    -								pSQLTimestamp->hour,pSQLTimestamp->minute,pSQLTimestamp->second);
    -				break;
    -			case SQLDTCODE_HOUR:
    -				DataLen = sprintf(cTmpBuf,"%02d",pSQLTimestamp->hour);
    -				break;
    -			case SQLDTCODE_HOUR_TO_MINUTE:
    -				DataLen = sprintf(cTmpBuf,"%02d:%02d",pSQLTimestamp->hour,pSQLTimestamp->minute);
    -				break;
    -			case SQLDTCODE_MINUTE:
    -				DataLen = sprintf(cTmpBuf,"%02d",pSQLTimestamp->minute);
    -				break;
    -			case SQLDTCODE_MINUTE_TO_SECOND:
    -				if (targetPrecision > 0)
    -					DataLen = sprintf(cTmpBuf,"%02d:%02d.%s",pSQLTimestamp->minute,pSQLTimestamp->second,cTmpFraction);
    -				else
    -					DataLen = sprintf(cTmpBuf,"%02d:%02d",pSQLTimestamp->minute,pSQLTimestamp->second);
    -				break;
    -			case SQLDTCODE_SECOND:
    -				if (targetPrecision > 0)
    -					DataLen = sprintf(cTmpBuf,"%02d.%s",pSQLTimestamp->second,cTmpFraction);
    -				else
    -					DataLen = sprintf(cTmpBuf,"%02d",pSQLTimestamp->second);
    -				break;
    -			default:
    -				if (targetPrecision > 0)
    -					DataLen = sprintf(cTmpBuf,"%04d-%02d-%02d %02d:%02d:%02d.%s",
    -								pSQLTimestamp->year,pSQLTimestamp->month,pSQLTimestamp->day,
    -								pSQLTimestamp->hour,pSQLTimestamp->minute,pSQLTimestamp->second,
    -								cTmpFraction);
    -				else
    -					DataLen = sprintf(cTmpBuf,"%04d-%02d-%02d %02d:%02d:%02d",
    -								pSQLTimestamp->year,pSQLTimestamp->month,pSQLTimestamp->day,
    -								pSQLTimestamp->hour,pSQLTimestamp->minute,pSQLTimestamp->second);
    -				break;
    +unsigned long  ODBC::ConvertToNumberSimple(SQLSMALLINT   CDataType,
    +        SQLPOINTER    srcDataPtr,
    +        SQLINTEGER    srcLength,
    +        CDescRec*     targetDescPtr,
    +        ICUConverter* iconv,
    +        SQLPOINTER    targetDataPtr, 
    +        UCHAR         *errorMsg)
    +{
    +    SQLSMALLINT    ODBCDataType    = targetDescPtr->m_ODBCDataType;
    +    SQLSMALLINT    SQLDataType     = targetDescPtr->m_SQLDataType;
    +    SQLSMALLINT    targetScale     = targetDescPtr->m_ODBCScale;
    +    SQLSMALLINT    targetUnsigned  = targetDescPtr->m_SQLUnsigned;
    +    SQLINTEGER     targetLength    = targetDescPtr->m_SQLOctetLength;
    +    SQLINTEGER     targetPrecision = targetDescPtr->m_ODBCPrecision;
    +    unsigned long  retCode         = SQL_SUCCESS;
    +    int            dec             = 0;
    +    int            sign            = 0;
    +    short          i               = 0;
    +    int            tempLen1        = 0;
    +    int            templen         = 0;
    +    int            numberLen       = 0;
    +    double         dTmp            = 0;
    +    double         dTmp1           = 0;
    +    UCHAR          utTmp           = 0;
    +    SCHAR          tTmp            = 0;
    +    SLONG_P        lTmp            = 0;
    +    float          fltTmp          = 0;
    +    SHORT          sTmp            = 0;
    +    USHORT         usTmp           = 0;
    +    ULONG_P        ulTmp           = 0;
    +    SQLINTEGER     DataLen         = DRVR_PENDING;
    +    SQLPOINTER     DataPtr         = NULL;
    +    BOOL           signedInteger   = FALSE;
    +    BOOL           negative        = FALSE;
    +    SQLINTEGER     translateLength = 0;
    +    char           srcDataLocale[CHARTMPLEN] = {0};
    +    int            tempLen         =  0;
    +    CHAR           cTmpBuf[TMPLEN]    = {0};
    +    CHAR           cCharTmpBuf[CHARTMPLEN]    = {0};
    +    __int64        tempVal64       = 0;
    +    __int64        integralPart    = 0;
    +    __int64        decimalPart     = 0;
    +    __int64        tempScaleVal64  = 0;
    +    long           leadZeros       = 0;
    +    long           decimalDigits   = 0;
    +    BOOL           useDouble       = TRUE;
    +    unsigned __int64  integralMax  = 0;
    +    unsigned __int64  decimalMax   = 0;
    +    double         scaleOffset     = 0;
    +    char *         tempPtr         = NULL;
    +    SQL_INTERVAL_STRUCT* intervalTmp = NULL;
    +
    +
    +    if(!(SQLDataType == SQLTYPECODE_NUMERIC || SQLDataType == SQLTYPECODE_NUMERIC_UNSIGNED))
    +        getMaxNum(targetPrecision, targetScale, integralMax, decimalMax);
    +
    +
    +
    +    if(ODBCDataType == SQL_REAL && CDataType == SQL_C_NUMERIC)
    +    {
    +        ConvertCNumericToChar((SQL_NUMERIC_STRUCT*)srcDataPtr, cCharTmpBuf);
    +        srcLength = strlen(cCharTmpBuf);
    +        if ((retCode = ConvertCharToNumeric(cCharTmpBuf, srcLength, dTmp)) != SQL_SUCCESS)
    +            return retCode;
    +        if (dTmp < -FLT_MAX || dTmp > FLT_MAX)
    +            return IDS_22_003;
    +        fltTmp = (SFLOAT)dTmp;
    +        DataPtr = &fltTmp;
    +        DataLen = sizeof(SFLOAT);
     
    -			}
    -			DataPtr = cTmpBuf;
    -		}
    -		if (DataLen != targetLength)
    -			return IDS_22_003;
    -		break; // End of SQL_TIMESTAMP
    -	case SQL_INTERVAL_MONTH:
    -	case SQL_INTERVAL_YEAR:
    -	case SQL_INTERVAL_YEAR_TO_MONTH:
    -	case SQL_INTERVAL_DAY:
    -	case SQL_INTERVAL_HOUR:
    -	case SQL_INTERVAL_MINUTE:
    -	case SQL_INTERVAL_SECOND:
    -	case SQL_INTERVAL_DAY_TO_HOUR:
    -	case SQL_INTERVAL_DAY_TO_MINUTE:
    -	case SQL_INTERVAL_DAY_TO_SECOND:
    -	case SQL_INTERVAL_HOUR_TO_MINUTE:
    -	case SQL_INTERVAL_HOUR_TO_SECOND:
    -	case SQL_INTERVAL_MINUTE_TO_SECOND:
    -		cTmpDataType = CDataType;
    -		if (CDataType == SQL_C_DEFAULT)
    -		{
    -			switch (ODBCDataType)
    -			{
    -			case SQL_INTERVAL_MONTH:
    -				cTmpDataType = SQL_C_INTERVAL_MONTH;
    -				break;
    -			case SQL_INTERVAL_YEAR:
    -				cTmpDataType = SQL_C_INTERVAL_YEAR;
    -				break;
    -			case SQL_INTERVAL_YEAR_TO_MONTH:
    -				cTmpDataType = SQL_C_INTERVAL_YEAR_TO_MONTH;
    -				break;
    -			case SQL_INTERVAL_DAY:
    -				cTmpDataType = SQL_C_INTERVAL_DAY;
    -				break;
    -			case SQL_INTERVAL_HOUR:
    -				cTmpDataType = SQL_C_INTERVAL_HOUR;
    -				break;
    -			case SQL_INTERVAL_MINUTE:
    -				cTmpDataType = SQL_C_INTERVAL_MINUTE;
    -				break;
    -			case SQL_INTERVAL_SECOND:
    -				cTmpDataType = SQL_C_INTERVAL_SECOND;
    -				break;
    -			case SQL_INTERVAL_DAY_TO_HOUR:
    -				cTmpDataType = SQL_C_INTERVAL_DAY_TO_HOUR;
    -				break;
    -			case SQL_INTERVAL_DAY_TO_MINUTE:
    -				cTmpDataType = SQL_C_INTERVAL_DAY_TO_MINUTE;
    -				break;
    -			case SQL_INTERVAL_DAY_TO_SECOND:
    -				cTmpDataType = SQL_C_INTERVAL_DAY_TO_SECOND;
    -				break;
    -			case SQL_INTERVAL_HOUR_TO_MINUTE:
    -				cTmpDataType = SQL_C_INTERVAL_HOUR_TO_MINUTE;
    -				break;
    -			case SQL_INTERVAL_HOUR_TO_SECOND:
    -				cTmpDataType = SQL_C_INTERVAL_HOUR_TO_SECOND;
    -				break;
    -			case SQL_INTERVAL_MINUTE_TO_SECOND:
    -				cTmpDataType = SQL_C_INTERVAL_MINUTE_TO_SECOND;
    -				break;
    -			default:
    -				return IDS_07_006;
    -			}
    -		}
    +    }
    +    else
    +    {
    +        switch (CDataType)
    +        {
    +            case SQL_C_INTERVAL_MONTH:
    +            case SQL_C_INTERVAL_YEAR:
    +            case SQL_C_INTERVAL_YEAR_TO_MONTH:
    +            case SQL_C_INTERVAL_DAY:
    +            case SQL_C_INTERVAL_HOUR:
    +            case SQL_C_INTERVAL_MINUTE:
    +            case SQL_C_INTERVAL_SECOND:
    +            case SQL_C_INTERVAL_DAY_TO_HOUR:
    +            case SQL_C_INTERVAL_DAY_TO_MINUTE:
    +            case SQL_C_INTERVAL_DAY_TO_SECOND:
    +            case SQL_C_INTERVAL_HOUR_TO_MINUTE:
    +            case SQL_C_INTERVAL_HOUR_TO_SECOND:
    +            case SQL_C_INTERVAL_MINUTE_TO_SECOND:
    +                if(ODBCDataType == SQL_REAL || ODBCDataType == SQL_FLOAT || ODBCDataType == SQL_DOUBLE)
    +                    return IDS_07_006;
    +            default:
    +                break;
    +        }
     
    -		switch (cTmpDataType)
    -		{
    -		case SQL_C_WCHAR:
    -			if (iconv->isAppUTF16())
    -			{
    -				if (srcLength != SQL_NTS)
    -					srcLength = srcLength/2;
    -				// translate from UTF16
    -				if (iconv->WCharToUTF8((UChar*)srcDataPtr, srcLength, srcDataLocale, sizeof(srcDataLocale), (int*)&translateLength, (char*)errorMsg) != SQL_SUCCESS)
    -					return IDS_193_DRVTODS_ERROR;
    -				srcDataPtr = srcDataLocale;
    -				srcLength = translateLength;
    -			}
    -		case SQL_C_CHAR:
    -			if (srcLength == SQL_NTS)
    -				DataLen = strlen((const char *)srcDataPtr);
    -			else
    -				DataLen = srcLength;
    -			if (StripIntervalLiterals(srcDataPtr, srcLength, ODBCDataType, cTmpBuf) != SQL_SUCCESS)
    -				return IDS_22_018;
    -			break;
    -		case SQL_C_BINARY:
    -			if (srcLength == SQL_NTS)
    -				DataLen = strlen((const char *)srcDataPtr);
    -			else
    -				DataLen = srcLength;
    -			strcpy(cTmpBuf, (const char *)srcDataPtr);
    -			break;
    -		case SQL_C_SHORT:
    -		case SQL_C_SSHORT:
    -			sTmp = *(SSHORT *)srcDataPtr;
    -			_ltoa(sTmp, cTmpBuf, 10);
    -			break;
    -		case SQL_C_USHORT:
    -			usTmp = *(USHORT *)srcDataPtr;
    -			_ultoa(usTmp, cTmpBuf, 10);
    -			break;
    -		case SQL_C_TINYINT:
    -		case SQL_C_STINYINT:
    -			sTmp = *(SCHAR *)srcDataPtr;
    -			_ltoa(sTmp, cTmpBuf, 10);
    -			break;
    -		case SQL_C_UTINYINT:
    -		case SQL_C_BIT:
    -			usTmp = *(UCHAR *)srcDataPtr;
    -			_ultoa(usTmp, cTmpBuf, 10);
    -			break;
    -		case SQL_C_SLONG:
    -		case SQL_C_LONG:
    -			lTmp = *(SLONG_P *)srcDataPtr;
    -			_ltoa(lTmp, cTmpBuf, 10);
    -			break;
    -		case SQL_C_ULONG:
    -			ulTmp = *(ULONG_P *)srcDataPtr;
    -			_ultoa(ulTmp, cTmpBuf, 10);
    -			break;
    -		case SQL_C_FLOAT:
    -			dTmp = *(float *)srcDataPtr;
    -			if (!double_to_char (dTmp, FLT_DIG, cTmpBuf, sizeof(cTmpBuf)))
    -				return IDS_22_001;
    -			break;
    -		case SQL_C_DOUBLE:
    -			dTmp = *(double *)srcDataPtr;
    -			if (!double_to_char (dTmp, DBL_DIG, cTmpBuf, sizeof(cTmpBuf)))
    -				return IDS_22_001;
    -			break;
    -		case SQL_C_NUMERIC:
    -			ConvertCNumericToChar((SQL_NUMERIC_STRUCT*)srcDataPtr, cTmpBuf);
    -			break;
    -		case SQL_C_SBIGINT:
    -#ifndef unixcli
    -			sprintf(cTmpBuf, "%I64d", *(__int64*)srcDataPtr);
    -#else
    -			sprintf(cTmpBuf, "%Ld", *(__int64*)srcDataPtr);
    -#endif
    -			break;
    -		case SQL_C_INTERVAL_MONTH:
    -			intervalTmp = (SQL_INTERVAL_STRUCT *)srcDataPtr;
    -			switch (ODBCDataType)
    -			{
    -			case SQL_INTERVAL_MONTH:
    -				if (intervalTmp->interval_sign == SQL_TRUE)
    -					sprintf(cTmpBuf,"-%ld",intervalTmp->intval.year_month.month);
    -				else
    -					sprintf(cTmpBuf,"%ld",intervalTmp->intval.year_month.month);
    -				break;
    -			case SQL_INTERVAL_YEAR_TO_MONTH:
    -				if (intervalTmp->interval_sign == SQL_TRUE)
    -					sprintf(cTmpBuf,"-00-%ld",intervalTmp->intval.year_month.month);
    -				else
    -					sprintf(cTmpBuf,"00-%ld",intervalTmp->intval.year_month.month);
    -				break;
    -			default:
    -				return IDS_07_006;
    -			}
    -			break;
    -		case SQL_C_INTERVAL_YEAR:
    -			intervalTmp = (SQL_INTERVAL_STRUCT *)srcDataPtr;
    -			switch (ODBCDataType)
    -			{
    -			case SQL_INTERVAL_YEAR:
    -				if (intervalTmp->interval_sign == SQL_TRUE)
    -					sprintf(cTmpBuf,"-%ld",intervalTmp->intval.year_month.year);
    -				else
    -					sprintf(cTmpBuf,"%ld",intervalTmp->intval.year_month.year);
    -				break;
    -			case SQL_INTERVAL_YEAR_TO_MONTH:
    -				if (intervalTmp->interval_sign == SQL_TRUE)
    -					sprintf(cTmpBuf,"-%ld-00",intervalTmp->intval.year_month.year);
    -				else
    -					sprintf(cTmpBuf,"%ld-00",intervalTmp->intval.year_month.year);
    -				break;
    -			default:
    -				return IDS_07_006;
    -			}
    -			break;
    -		case SQL_C_INTERVAL_YEAR_TO_MONTH:
    -			intervalTmp = (SQL_INTERVAL_STRUCT *)srcDataPtr;
    -			switch (ODBCDataType)
    -			{
    -			case SQL_INTERVAL_YEAR:
    -				if (intervalTmp->interval_sign == SQL_TRUE)
    -					sprintf(cTmpBuf,"-%ld",intervalTmp->intval.year_month.year);
    -				else
    -					sprintf(cTmpBuf,"%ld",intervalTmp->intval.year_month.year);
    -				break;
    -			case SQL_INTERVAL_MONTH:
    -				if (intervalTmp->interval_sign == SQL_TRUE)
    -					sprintf(cTmpBuf,"-%ld", intervalTmp->intval.year_month.month);
    -				else
    -					sprintf(cTmpBuf,"%ld", intervalTmp->intval.year_month.month);
    -				break;
    -			case SQL_INTERVAL_YEAR_TO_MONTH:
    -				if (intervalTmp->interval_sign == SQL_TRUE)
    -					sprintf(cTmpBuf,"-%ld-%ld",intervalTmp->intval.year_month.year, intervalTmp->intval.year_month.month);
    -				else
    -					sprintf(cTmpBuf,"%ld-%ld",intervalTmp->intval.year_month.year, intervalTmp->intval.year_month.month);
    -				break;
    -			default:
    -				return IDS_07_006;
    -			}
    -			break;
    -		case SQL_C_INTERVAL_DAY:
    -			intervalTmp = (SQL_INTERVAL_STRUCT *)srcDataPtr;
    -			switch (ODBCDataType)
    -			{
    -			case SQL_INTERVAL_DAY:
    -				if (intervalTmp->interval_sign == SQL_TRUE)
    -					sprintf(cTmpBuf,"-%ld",intervalTmp->intval.day_second.day);
    -				else
    -					sprintf(cTmpBuf,"%ld",intervalTmp->intval.day_second.day);
    -				break;
    -			case SQL_INTERVAL_DAY_TO_HOUR:
    -				if (intervalTmp->interval_sign == SQL_TRUE)
    -					sprintf(cTmpBuf,"-%ld 00",intervalTmp->intval.day_second.day);
    -				else
    -					sprintf(cTmpBuf,"%ld 00",intervalTmp->intval.day_second.day);
    -				break;
    -			case SQL_INTERVAL_DAY_TO_MINUTE:
    -				if (intervalTmp->interval_sign == SQL_TRUE)
    -					sprintf(cTmpBuf,"-%ld 00:00",intervalTmp->intval.day_second.day);
    -				else
    -					sprintf(cTmpBuf,"%ld 00:00",intervalTmp->intval.day_second.day);
    -				break;
    -			case SQL_INTERVAL_DAY_TO_SECOND:
    -				if (intervalTmp->interval_sign == SQL_TRUE)
    -					sprintf(cTmpBuf,"-%ld 00:00:00",intervalTmp->intval.day_second.day);
    -				else
    -					sprintf(cTmpBuf,"%ld 00:00:00",intervalTmp->intval.day_second.day);
    -				break;
    -			default:
    -				return IDS_07_006;
    -			}
    -			break;
    -		case SQL_C_INTERVAL_HOUR:
    -			intervalTmp = (SQL_INTERVAL_STRUCT *)srcDataPtr;
    -			switch (ODBCDataType)
    -			{
    -			case SQL_INTERVAL_HOUR:
    -				if (intervalTmp->interval_sign == SQL_TRUE)
    -					sprintf(cTmpBuf,"-%ld",intervalTmp->intval.day_second.hour);
    -				else
    -					sprintf(cTmpBuf,"%ld",intervalTmp->intval.day_second.hour);
    -				break;
    -			case SQL_INTERVAL_DAY_TO_HOUR:
    -				if (intervalTmp->interval_sign == SQL_TRUE)
    -					sprintf(cTmpBuf,"-00 %ld",intervalTmp->intval.day_second.hour);
    -				else
    -					sprintf(cTmpBuf,"00 %ld",intervalTmp->intval.day_second.hour);
    -				break;
    -			case SQL_INTERVAL_DAY_TO_MINUTE:
    -				if (intervalTmp
    --- End diff --
    
    Do we need to null-terminate the two strncpy's above?


---

Mime
View raw message