2 Replies - 930 Views - Last Post: 08 November 2009 - 03:32 AM Rate Topic: -----

#1 mihaispr  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 114
  • Joined: 29-September 09

Little Problem with INSERT INTO

Posted 07 November 2009 - 05:58 AM

Hi everyone and thanks for reading my question!

I have a problem in table2(TipuriAutomobile) and table3 (FoaieParcursMasina) in the sense that it doesn't inserts all the rows only a part of rows are inserted and I specified him how to insert using INSERT INTO.

Here is the full DDL:
CREATE TABLE TipuriAutomobile
(IdTip int PRIMARY KEY NOT NULL,
IdMasina int,
TipAutomobil varchar(255),
CapacitateMotor varchar(255),
CapacitateTransport varchar(255),
TipCombustibil varchar(255),
NormaL100KM decimal(3,2) -- 3 zecimale in total , 2 zecimale dupa virgula
)




This is OK. I use Sql Server Management Studio.

Now here is the problem when I use INSERT INTO:

INSERT INTO TipuriAutomobile(IdTip,IdMasina,TipAutomobil,CapacitateMotor,CapacitateTransport,TipCombustibil,NormaL100KM)
VALUES(1,1,'auto-cisterna','340kw','9000kg','motorina',8.93); 
 
INSERT INTO TipuriAutomobile(IdTip,IdMasina,TipAutomobil,CapacitateMotor,CapacitateTransport,TipCombustibil,NormaL100KM)
VALUES(2,2,'camion','320kw','7000kg','benzina',12.09); 
 
INSERT INTO TipuriAutomobile(IdTip,IdMasina,TipAutomobil,CapacitateMotor,CapacitateTransport,TipCombustibil,NormaL100KM)
VALUES(3,3,'auto-utilitara','300kw','8500kg','GPL',10.29); 
 
INSERT INTO TipuriAutomobile(IdTip,IdMasina,TipAutomobil,CapacitateMotor,CapacitateTransport,TipCombustibil,NormaL100KM)
VALUES(4,4,'basculanta','290kw','5500kg','benzina',11.39); 
 



Error received:


(1 row(s) affected)
Msg 8115, Level 16, State 8, Line 4
Arithmetic overflow error converting numeric to data type numeric.
The statement has been terminated.
Msg 8115, Level 16, State 8, Line 7
Arithmetic overflow error converting numeric to data type numeric.
The statement has been terminated.
Msg 8115, Level 16, State 8, Line 10
Arithmetic overflow error converting numeric to data type numeric.
The statement has been terminated.



Please tell me what I'm wrong the syntax looks correct it must affect 4 rows why he is affecting 1 row of my table called TipuriAutomobile?

This post has been edited by mihaispr: 07 November 2009 - 09:51 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Little Problem with INSERT INTO

#2 cmwise  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 169
  • Joined: 14-February 09

Re: Little Problem with INSERT INTO

Posted 07 November 2009 - 06:32 PM

Hey,

Have you tried not inputting the primary key id? As in, using AUTO_INCREMENT or something?

I really can't see anything wrong with your SQL or anything else, but I'd try changing it to auto_increment just for troubleshooting... it's all I can think of doing.

Sorry if this isn't very helpful :-\
Was This Post Helpful? 1
  • +
  • -

#3 mihaispr  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 114
  • Joined: 29-September 09

Re: Little Problem with INSERT INTO

Posted 08 November 2009 - 03:32 AM

Thanks!

I solved it!

Was Decimal(4,2) in the field NormaL100KM because I put in insert into 10.23.

And that was the problem.

Thanks anyway!

Best wishes,

Michael
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1