Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Error: Data would be truncated
Message
From
05/07/2006 07:22:10
 
 
To
04/07/2006 03:47:22
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01133038
Message ID:
01133766
Views:
14
>>>>>>Getting the message 'String or binary data would be truncated.' when I try to save an updated remote view back to SQL Server.
>>>>>>
>>>>>>Only one field in the view is set to Updateable and that field is defined as decimal (15,2) in SQL Server. The view, as initially set in ViewEditor, had the field defined as N(17,2). I changed it to N(15,2) and still got the error. I also tried N(10,2) and, after Del Lee pointed out that SQL Server doesn't count the decimal in the length of the field, N(16,2). In all cases I get the same error and the table isn't updated.
>>>>>>
>>>>>>Can anyone suggest what else I should be checking?
>>>>>>
>>>>>>TIA
>>>>>
>>>>>Jim,
>>>>>
>>>>>VFP map MSSQL decimal(X,Y) to N(X+2,Y),
>>>>>but map N(Z,W) to MSSQL Float ( Double ) or CHAR() ( I don't remember exactly );
>>>>>this conversion change the value to
>>>>>
>>>>>SELECT CAST(10.47 AS FLOAT)
>>>>>-- 10.470000000000001
>>>>>
>>>>>
>>>>>When MSSQL convert 10.470000000000001 to D(15,2) the last digit "1" must to be truncated.
>>>>>
>>>>
>>>>>Verify this with SQL Profile.
>>>>>
>>>>>This is a VFP's bad design for me.
>>>>>
>>>>>A bad workaround is
>>>>>
>>>>>
>>>>>SET NUMERIC_ROUNDABORT OFF
>>>>>
>>>>>
>>>>>
>>>>>Fabio
>>>>
>>>>Fabio,
>>>>
>>>>I tried SQLEXEC(lnHandle,'SET NUMERIC_ROUNDABORT OFF') just before the update but it had no effect. Still getting the same error message and no update.
>>>>
>>>>Any other ideas?
>>>>
>>>>Regards,
>>>
>>>Capture, with SQL Profile, the RV update session, then post it.
>>
>>
>>OK, here's what I got with SQL Profile:
>>
>>set implicit_transactions on
>>SET NUMERIC_ROUNDABORT OFF
>>exec sp_executesql N'UPDATE dbo.tblInventoryPrice SET pri_Current_Price=@P1 WHERE own_Owner_Code=@P2 AND inp_Short_Item_Number=@P3 AND prl_Price_List_Code=@P4 AND pri_term=@P5', N'@P1 decimal(15,2),@P2 char(2),@P3 char(10),@P4 char(1),@P5 smallint', 10.47, 'PA', 'BRUS-0016 ', 'R', 1
>>IF @@TRANCOUNT > 0 ROLLBACK TRAN
>>
>
>vfpt has fixed the N(X,Y) mapping ?
>
>By the way, this code works in my SQL QA
>
>create table #tblInventoryPrice (
>	pri_Current_Price decimal(15,2)
>,	own_Owner_Code	char(2)
>,	inp_Short_Item_Number	char(10)
>,	prl_Price_List_Code	char(1)
>,	pri_term	smallint)
>
>insert into #tblInventoryPrice
>values
>(0.0, 'PA', 'BRUS-0016 ', 'R', 1)
>
>set implicit_transactions on
>SET NUMERIC_ROUNDABORT ON
>exec sp_executesql N'UPDATE #tblInventoryPrice SET pri_Current_Price=@P1 WHERE own_Owner_Code=@P2 AND inp_Short_Item_Number=@P3 AND prl_Price_List_Code=@P4 AND pri_term=@P5', N'@P1 decimal(15,2),@P2 char(2),@P3 char(10),@P4 char(1),@P5 smallint', 10.47, 'PA', 'BRUS-0016 ', 'R', 1
>
>SELECT * FROM #tblInventoryPrice
>
>drop table  #tblInventoryPrice
>
Yes, using QA and just the update command works fine. It's getting the view to update the table that's a problem.

Regards,
Jim
Previous
Reply
Map
View

Click here to load this message in the networking platform