none
Decimal(19,2) column data missing leading zero when value <1.0 through OLEDB

    Question

  • My column is defined as type decimal(19,2). When I select data through OLEDB(C++), I got .12 if the value is 0.12. The leading 0 is always missing. How do I define a right format of this kind of column? Here is my code fragment.

       // Construct the binding array element for each column
       for( iCol = 0; iCol < cColumns; iCol++ )
       {
          // Bind this column as DBTYPE_WSTR, which tells the provider to
          // copy a Unicode string representation of the data into our buffer,
          // converting from the native type if necessary
          rgBindings[iCol].wType        = DBTYPE_STR;
       }



    • Edited by Percy Xu Thursday, February 20, 2014 11:16 AM
    Thursday, February 20, 2014 11:05 AM

Answers

  • why do you need to do this? 0.12 and .12 represents same value so if your concern is more in terms of displaying value then you can use format functions in front end to display it.

    there's no need of changing base datatype to string just for  this need IMHO


    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

    • Marked as answer by Percy Xu Thursday, February 20, 2014 1:46 PM
    Thursday, February 20, 2014 12:02 PM

All replies


  • Convert this value to String on back-end before returning on Application.
    Thursday, February 20, 2014 11:36 AM

  • Convert this value to String on back-end before returning on Application.

    Do you mean like this?

    SELECT cast( convert(numeric(20,2), 0) as nvarchar(50)) as [zero_column];

    Thursday, February 20, 2014 12:00 PM
  • why do you need to do this? 0.12 and .12 represents same value so if your concern is more in terms of displaying value then you can use format functions in front end to display it.

    there's no need of changing base datatype to string just for  this need IMHO


    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

    • Marked as answer by Percy Xu Thursday, February 20, 2014 1:46 PM
    Thursday, February 20, 2014 12:02 PM
  • why do you need to do this? 0.12 and .12 represents same value so if your concern is more in terms of displaying value then you can use format functions in front end to display it.

    there's no need of changing base datatype to string just for  this need IMHO


    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs


    It may be convinient for front-end to just display anything from a db query.
    Thursday, February 20, 2014 12:50 PM