Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: integer
I wrote a script that creates a test Access database, then creates a single table called testnum with a NUMBER column. Then several rows are added using several techniques.
I have never had the need to insert numbers more than 10-digits so any anomalies never appeared. Just curious.
cMDB = StrCat(dirget(),"test.mdb") ; access 97 - Conn = "Provider=MicroSoft.Jet.OLEDB.4.0; Data Source=%cMDB%;Jet OLEDB:Engine Type=4" Conn = "Provider=MicroSoft.Jet.OLEDB.4.0; Data Source=%cMDB%;" If FileExist( cMDB ) Then FileDelete( cMDB ) cat = ObjectOpen("ADOX.Catalog") cat.Create(Conn) ObjectClose( cat ) DB = ObjectOpen("ADODB.Connection") RS = ObjectOpen("ADODB.Recordset") DB.Open( Conn ) DB.Execute( "CREATE TABLE TESTNUM ( NUM NUMBER );" ) ;SQL treats everything as string DB.Execute( "INSERT INTO TESTNUM ( NUM ) VALUES ( '1234567899' );" ) RS = ObjectOpen("ADODB.Recordset") RS.Open("TESTNUM",Conn,2,3,2) fld = RS.fields(0) RS.addnew() fld.Value = 12345678999 ; will add as negative number RS.Update() RS.addnew() fld.Value = ObjectType("UI4",12345678999) ; should not be possible RS.Update() RS.addnew() fld.Value = 12345678 * 1000 ;another negative RS.Update() RS.addnew() fld.Value = 12345678 RS.Update() n = fld.value fld.Value = n*1000 ;now should enter 11-digit value RS.Update() ObjectClose(RS) DB.Close() ObjectClose(DB)
There is a #DECIMAL: datatype that WinBatch and ole support for large integers. Goes up to lots of digits. To WinBatch it is a string, but it is coverted to a large integer while passing thru OLE.
number format is
"#DECIMAL:123456789012345678901234567890.1234567890"with up to (I think) 96 digits. The #DECIMAL: is plastered on the front of the numer so that WinBatch will not try to assume it is a number and trash it....
NOTE: The Winbatch standard number range is -2.1 billionto 2.1 billion.-2100000000 to 2100000000 (approx) so you can see it can handle 9 digit numbers, but once you hit 10 digit numbers you may be in trouble.
I guess I just have to test plucking a few 17-18 digit numbers from Excel and inserting them into a database.
This may be one for the 'gotcha' documentation - or how to avoid problems using large numbers with ADO.
My personal preference is to always perform INSERTS, UPDATES and DELETES from SQL rather than ADO code ( like addnew() ), as you can write little ascii .cmd files and execute a line at a time.
;TESTXLNU.WBT cXLS = StrCat( dirget(),"test.xls") oAPP = ObjectOpen( "Excel.Application" ) oAPP.Visible = @TRUE oWK = oAPP.workbooks oWK.open(cXLS) oACT = oAPP.ActiveWorkbook oWKS = oAPP.Worksheets oWS = oAPP.Worksheets(1) oWS.Activate oCell = oWS.Cells(1,1) n = oCell.Value oCell = oWS.Cells(2,1) oCell.Value = n*100 ObjectClose(oWS) ObjectClose(oWK) ObjectClose(oACT) ObjectClose(oAPP) Exit
;BIGNUM.WBT cXML = StrCat( dirget(), "bignum.xml" ) If FileExist( cXML ) Then FileDelete( cXML ) adUseClient = 3 adDouble = 5 RS = ObjectOpen("ADODB.RecordSet") RS.CursorLocation = adUseClient flds = RS.Fields flds.append("Number",adDouble) RS.Open() f1 = RS.Fields("Number") RS.Addnew() f1.Value = 12345678999 RS.Update() RS.Addnew() f1.Value = '12345678999' RS.Update() RS.Save( cXML, 1 ) RS.Close() ObjectClose( RS ) Exit
Article ID: W15592
File Created: 2003:05:13:11:29:08
Last Updated: 2003:05:13:11:29:08