Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problem with decimals in remote views with Oracle
Message
From
07/11/2000 13:24:54
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00438691
Message ID:
00438904
Views:
22
Thanks for answering Mark.
Dbgetprop("stocksdeuno.nmpieenti", "field", "datatype") returns n(18, 3)
If i see the browse window without puting the focus in this field, i see 3,36
However if i test '? stocksdeuno.nmpieenti' returns 3,000
And operating with it uses 3,000
¿what can i do?
I have imported this oracle tables into fox ones and the same behavior occurs. If i pack the fox tables, problem disappears.
TIA

>>Behavior:
>>I open a remote view that takes data from oracle database. In browse window i see decimals (in a courious mode but i see them), but if i put the cursor in the field or i try to operate with this value or simply displaying it, i lose the decimals obtaining a rounded value. ¿what am i doing bad?
>>TIA
>
>Does the corresponding Oracle field have decimal places? Does --
>
>DBGetProp('MyView.MyField', 'Field', 'DataType')
>
>return the correct field length and decimals? If not you can --
>
>DBSetProp('MyView.MyField', 'Field', 'DataType', 'N(x,y)')
>
>to correct the formatting of the views. Keep in mind, everytime you modify the view and save it, you will have to reissue the DBSetProp() commands. Here is some code I use to fix my Oracle views. THis code will convert all Oracle DateTime fields to Date only. So, use that part only if needed.
>lnHandle = sqlconnect()   && connect as the schema onwer [user]
>if lnHandle < 1
>   return
>endif
>lnRetVal = sqlexec(lnHandle, 'select table_name, column_name, data_type, data_length, ';
>       + 'data_precision, data_scale from cols order by 1, 2','crsFields')
>if lnRetVal < 1
>   MessageBox("View Correction failed!", MB_ICONSTOP, "ERROR!")
>   return
>endif
>select crsFields
>locate
>scan
>   lcTable  = 'v_' + trim(crsFields.Table_Name)
>   lcField  = trim(crsFields.Column_Name)
>   if !indbc(lcTable + '.' + lcField, 'Field')
>      loop
>   endif
>   if isnull(crsFields.Data_Length) or crsFields.Data_Length = 0
>      loop
>   endif
>   do case
>      case inlist(crsFields.Data_Type, 'CHAR', 'VARCHAR2')
>         lnLength = alltrim(str(crsFields.Data_Length))
>         DBSetProp(lcTable + '.' + lcField, 'Field', 'DataType', 'C(&lnLength)')
>      case crsFields.Data_Type = 'DATE'
>         DBSetProp(lcTable + '.' + lcField, 'Field', 'DataType', 'D')
>      case crsFields.Data_Type = 'NUMBER'
>         lnLength = alltrim(str(nvl(crsFields.Data_Precision, 8)))
>         lnScale  = alltrim(str(nvl(crsFields.Data_Scale, 0)))
>         if inlist(val(lnLength), 8, 10) and val(lnScale) = 0      && lcField = "KEYID"
>            DBSetProp(lcTable + '.' + lcField, 'Field', 'DataType', 'I')
>         else
>            if val(lnScale) = 0
>               DBSetProp(lcTable + '.' + lcField, 'Field', 'DataType', 'N(&lnLength)')
>            else
>               DBSetProp(lcTable + '.' + lcField, 'Field', 'DataType', 'N(&lnLength, &lnScale)')
>            endif
>         endif
>      case crsFields.Data_Type = 'LONG'
>         DBSetProp(lcTable + '.' + lcField, 'Field', 'DataType', 'M')
>   endcase
>endscan
Saludos,
A.G.P.
---------
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform