Discussions related to Visual Prolog
loveProlog
Posts: 8
Joined: 9 Jul 2014 12:53

Numeric value out of range" exception in fetch_nd() of VIP 7.4 application

Unread post by loveProlog »

We have the same application written in 5.2 & 7.4 on the same SQL DB.
There is a column defined as numeric (12,0). When retrieving the data (has value greater than max of integer, for example, 5000000370) from two applications on 5.2 & 7.4, 5.3 application works w/o any error. But 7.3 application throws "Numeric value out of range" exception.

I understand the reason why it throws the exception since the value (5000000370) is greater than max of integer. The workaround is to define as varchar.

What I do not understand is that why it was working fine in 5.2 application.
I am using fetch_nd() in 7.4 application and sql_FetchNext(Stmt) in 5.2 application

I will appreciate your help in advance
User avatar
Thomas Linder Puls
VIP Member
Posts: 1398
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls »

Well, it can obviously not work in vip5.2: It may not raise an exception, but the result must be wrong, because also in Vip5.2 an integer cannot represent the mentioned number.

I am not really sure what you want help with?
Regards Thomas Linder Puls
PDC
loveProlog
Posts: 8
Joined: 9 Jul 2014 12:53

Unread post by loveProlog »

My question was why 5.2 apps worked but 7.4 apps raised the exception.
I tested the same scenario in both version apps.
5.2 apps worked as expected.
I was wondering maybe 5.2 & 7.4 support different version of odbc.
User avatar
Thomas Linder Puls
VIP Member
Posts: 1398
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls »

In my mind it is the Vip 7.4 program that work and the Vip 5.2 doesn't work, it does not raise an exception for an overflow/out of range problem that does indeed exist, instead it simply returns a wrong value.

My guess is that you simply receive those bits of the number that fits into a 32bit integer. Your number is 0x12A05F372 (i.e. in hex) fitting it to 32bit gives 0x2A05F372 which is 705033074 in decimal.

If you use the same ODBC connection then you also use the same driver, there may be a difference in various parameter settings used by the two programs, but here it seems that the Vip5.2 program ignores an overflow/our of range error somewhere.
Regards Thomas Linder Puls
PDC
Post Reply