Marco,
In your example please change this line:
msginfo(str(88.456,10, Int( nDecimals ) )) && RETURN 88 !!!
Marco,
In your example please change this line:
msginfo(str(88.456,10, Int( nDecimals ) )) && RETURN 88 !!!
As you said you created the table with column as SHORTINT. This type is giving problems.
Create the column as INT and it works well. Please populate the data afresh. Please do not copy with SQL statements.
I tested with ADO and shared my observations with you.
Another advice: Use FWH Ado functions and ADO and you will not go wrong. I am afraid of other libraries.
I did not get any problem first because I used FWH library functions. I tried many times. What saved me was that I used FWH function to create the table, which used the correct datatype, ie INT and not SMALLINT.
Trust ADO and Trust FWH.
function testsql3
local oCn, oRs
local nDecimals
oCn := FW_OpenAdoConnection( "test3.db" )
if oCn:State < 1
? "fail"
return nil
endif
TRY
oCn:Execute( "DROP TABLE NUMDEC" )
CATCH
END
// Create Table and populate data
FWAdoCreateTable( "NUMDEC", { { "DATE", 'D', 8, 0 }, ;
{ "NDECIMALS", 'N', 2, 0 } }, oCn, .f. )
oRs := FW_OpenRecordSet( oCn, "NUMDEC" )
oRs:AddNew( { "Date", "NDECIMALS" }, { Date(), 3 } )
oRs:Close()
// Open Table and Use data
oRs := FW_OpenRecordSet( oCn, "NUMDEC" )
nDecimals := oRs:Fields( "nDecimals" ):Value
? nDecimals, ValType( nDecimals )
msginfo( Str( 88.456, 10, 3 ) )
msginfo( Str( 88.456, 10, nDecimals ) )
oRs:Close()
oCn:Close()
return nilHi Rao,
I understand but SMALLINT runs well with xHarbour 1.2.1 rev 9656.
What did you change from that version to 1.2.3 rev build 20141106 to affect smallint ?
I know I can use ado but using a direct lib to access the db is quicker and it's a very long job to change and test anything on ado on any OS configuration,
do you think it could be possible to solve the problem on the xharbour side ? Sqlite is a great db, open source, and all C source code is avalable all of us.
It isn't a sqlite related problem, only an xharbour problem,
if we, software programmers are not sure anymore if xharbour manages any numeric value in a proper way and in any situation......
Antonio Linares wrote:Marco,
In your example please change this line:
msginfo(str(88.456,10, Int( nDecimals ) )) && RETURN 88 !!!
Marco,
Is it working fine with Harbour ?
Antonio Linares wrote:Marco,
Is it working fine with Harbour ?
Marco,
Do you use somewhere in your code SET DECIMALS TO ... ?
In my example xHarbour behaves ok, so its really strange that your code is failing...
Hi, yes I have a SET DECIMAL TO 7
Hi Antonio,
I have tested the self contained sample with and without SET DECIMALS but the problem appear in any way.
Pls. find at http://109.228.12.120/softwaredistribut ... /test1.rar the self contained with also executable that show the problem.
You have attempted to define the scope of the nDecimals variable?
Local ..
Static ..
etc
Hi,
no I didn't. As you can see the self-contained is very minimal.
procedure start()
oSQLite := TSQLiteServer():New( "test.sql" )
If oSQLite:lError
msgStop( "error" )
RETURN
EndIf
cQuery:="SELECT * from t_tables;"
oQry:=oSQLite:Query(cQuery)
nDecimals:=oQry:aData[1,7]
oQry:End()
oSQLite:End()
msginfo(ndecimals) && return 3
msginfo(valtype(ndecimals)) && return N
msginfo(str(88.456,10,3)) && return 88.456
msginfo(str(88.456,10,nDecimals)) && RETURN 88 !!!
return
function gettemppath()
return("")
Marco Turco wrote:Hi,
no I didn't. As you can see the self-contained is very minimal.
---
#include "fivewin.ch"
procedure start()
oSQLite := TSQLiteServer():New( "test.sql" )
If oSQLite:lError
msgStop( "error" )
RETURN
EndIf
cQuery:="SELECT * from t_tables;"
oQry:=oSQLite:Query(cQuery)
nDecimals:=oQry:aData[1,7]
oQry:End()
oSQLite:End()
msginfo(ndecimals) && return 3
msginfo(valtype(ndecimals)) && return N
msginfo(str(88.456,10,3)) && return 88.456
msginfo(str(88.456,10,nDecimals)) && RETURN 88 !!!
return
function gettemppath()
return("")
#include "fivewin.ch"
procedure start()
Local ndecimals := 0 //Hi cnavarro,
I have tried but the problem is still in place.
msginfo(str(88.456,10,nDecimals)) Always return 88
#include "fivewin.ch"
procedure start()
Local nTest_Decimals := 3
oSQLite := TSQLiteServer():New( "test.sql" )
If oSQLite:lError
msgStop( "error" )
RETURN
EndIf
cQuery:="SELECT * from t_tables;"
oQry:=oSQLite:Query(cQuery)
nTest_Decimals :=oQry:aData[1,7]
oQry:End()
oSQLite:End()
msginfo(nTest_Decimals ) && return 3
msginfo(valtype(nTest_Decimals )) && return N
msginfo(str(88.456,10,3)) && return 88.456
msginfo(str(88.456,10,nTest_Decimals )) && RETURN 88 !!!
return
function gettemppath()
return("")