Skip to content

[QUESTION] Decimal values scale on bulk insert #1021

@RazmikMkrtchyan

Description

@RazmikMkrtchyan

Question

Relevant Issues and Pull Requests

During bulk insert decimal values get rounding.
I did the profile and got the following query:

exec sp_executesql N'insert into DE_PartnerPayment
(PaymentDescription, PartnerPaymentID, PartnerID, Amount, PlannedPaymentDate, PlannedFinancialReportDate)
values (P0, P1, P2, P3, P4, P5), (P6, P7, P8, P9, P10, P11)',
N'@p0 nvarchar(4000),P1 int,@p2 int,P3 decimal(38,1),P4 datetime2,P5 datetime2,P6 nvarchar(4000),P7 int,P8 int,P9 decimal(38,4),P10 datetime2,P11 datetime2',
N'aaaa',1060,744,13.1,'2019-04-02 09:28:55','2019-04-02 09:28:55',N'aaaa',1061,744,13.9999,'2019-04-02 09:28:55','2019-04-02 09:28:55'

For each bigDecimal value its scale is puts In the query, but ms-sql does not understand and takes only the type of the first one.

In Parameter.java works following code
void execute(DTV dtv, BigDecimal bigDecimalValue) throws SQLServerException {
if (null != bigDecimalValue) {
scale = bigDecimalValue.scale();
if (scale < 0)
scale = 0;
}
setTypeDefinition(dtv);
}

Wouldn't it be right to define the scale with column type?

Metadata

Metadata

Assignees

Labels

EnhancementAn enhancement to the driver. Lower priority than bugs.QuestionUsed when a question is asked, as opposed to an issue being raised

Type

No type

Projects

Status

Closed Issues

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions