Insert decimal variable in firebird

0

I'm doing an Insert in the Firebird database in a UnitUnit (decimal) field, but the decimal places in the table do not appear.

C # code:

public decimal ValorUnitario { get; set; }

produto.ValorUnitario = Convert.ToDecimal(5.50);
string sql = $"INSERT INTO PRODUTO(VALOR_UNITARIO)VALUES('{produto.ValorUnitario}');

In the database insert UnitUnvalue = 55

    
asked by anonymous 04.01.2017 / 20:56

3 answers

0

The problem is not fully clarified in the question because the structure of the tables involved is not included.

More information about Firebird's numeric data types can be accessed at: Fixed-Point Data Types

Create a test table with the following DDL:

CREATE TABLE TESTE (
ID     INTEGER NOT NULL,
NOME   VARCHAR(40) NOT NULL,
VALOR  DECIMAL(15,2));

Insert a record with the command:

insert into teste(id, nome, valor) values(101,'teste', 4.52);
commit;

In the test performed, with the commands executed by ibexpert the result was expected.

    
05.01.2017 / 18:07
1

The problem was solved by making a change in the table structure, before my field VALUE_UNITARIO was a decimal (18,0) and I made a change by changing the field structure to decimal (18,2).

ALTER TABLE PRODUTO ALTER COLUMN VALOR_UNITARIO TYPE DECIMAL(18,2); – @Edison 
    
12.01.2017 / 11:56
0

I do not work with C # but is using product.ValueUnitrix to convert the value and entity.ValueUnitale to concatenate the SQL String. If this is correct, okay, but check the contents of the SQL variable, which contains the command to be executed, maybe there you will find the problem. For Firebird the decimal format must be separated by "." or 5.5

    
04.01.2017 / 21:15