Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Importing negative values
Message
From
16/09/2005 05:50:54
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Oracle
Miscellaneous
Thread ID:
01050169
Message ID:
01050172
Views:
11
>Hi
>
>I am having trouble importing data which comes from an Oracle database (via a delimited text file)
>
>The problem is with negaitve numbers. Oracle appears to be exporting them in the format 1.00- instead of the more usual -1.00 and I can't get FoxPro to import the data properly - it just imports the value 1.00
>
>Any ideas - is there anything I can do with FoxPro or does the data have to be exported differently from Oracle?
>
>thanks for your help
>
>John

John,
If it'd be imported from a text file, then first create an intermediate cursor with the same structure except you r number fields as char. ie: If myValue is integer or n(6,2) then in your intermediate cursor make it c(20). Append from delimited file. Replace all ending with xxx.yy- to -xxx.yy. Change type back to numeric and append to your original table.
ie:
Create Cursor original (v1 i, v2 N(10,2), v3 b(5), v4 c(10))

Local ix,lcTemp,mlcSample
TEXT to m.lcSample noshow
123,  10.54,   1.12345, "rec1"
123,  10.54,   1.12345-,"rec2"
123,  10.54-,  1.12345, "rec3"
123-, 10.54,   1.12345, "rec4"
123-, 10.54-,  1.12345, "rec5"
ENDTEXT

lcTemp = Forcepath(Sys(2015)+'.txt',Sys(2023))
Strtofile(m.lcSample,m.lcTemp)

Select original
Afields(aStruc)
For ix=1 To Alen(aStruc,1)
  If aStruc[m.ix,2] $ 'YFBNI'
    aStruc[m.ix,2] = 'C'
    aStruc[m.ix,3] = 20
    aStruc[m.ix,4] = 0
  Endif
Endfor
Create Cursor intermediate From Array aStruc
Append From (m.lcTemp) Type Delimited
Erase (m.lcTemp)
For ix=1 To Fcount()
  If Type('original.'+Field(m.ix)) $ 'YFBNI'
    Replace (Field(m.ix)) ;
      With '-'+Ltrim(Evaluate(Field(m.ix))) ;
      for Right(Trim(Evaluate(Field(m.ix))),1)='-' ;
      In ('intermediate')
  Endif
Endfor

Select original
Append From Dbf('intermediate')
Use In 'intermediate'
Browse
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform