Can be simplified and simplified, and the functions of CA plus are enhanced.
(1) automatically generate cursorschema. In this case, the length of the backend field/decimal point can be automatically adapted to the front-end when there is a change.
Then change the CA, and the input interface is also adapted, which is much more convenient.
In addition, the Ca/SPT of fox9 has a bug in the ing length of n-type fields.CodeFix the issue.
Numeric definition comparison
(1) No decimal places
SQL: N 5-> the number is 5 in length. The maximum number that can be expressed is 99999.
Vfpl: N 5-> the total length of the number is 5. the maximum number that can be expressed is 99999.
When retrieving SQL data from VFP using SPT or Ca,For the field N 5 on the SQL end, the VFP end is actually N 7. If you enter this length, an error occurs during update.
Processing: For integers, the length of the integer is reduced by 2.
(2) Decimals
SQL: N 5.2-> the full length of the number is 5, where the integer part has three digits and the decimal point has two digits. The decimal point is not counted within the length. The maximum number that can be expressed is 999.99.
VFP: N 5.2-> the full length of the decimal point is 5, of which the second decimal point is used. The decimal point is within the length. The maximum number that can be expressed is 99.99 (1 digit smaller than above)
RetrieveFor the SQL end N (5.2) (999.99) field, the VFP end is n 7.2 (9999.99 ).That is, the VFP end has one more digit before the decimal point .. It should be n6.2.
Processing: For decimal places, the length of the integer part is reduced by 1.
Local csql, ckeyword, narea, cschema, I,Ctype, CTMP, ntmp, clenght, cdecimal
Narea=Select()
*-- If curorschema is empty and no relevant attributes have been modified --> Automatically generate curorschema
If Not (Pemstatus (this, ' _ Vfpsetup ', 5) and this. _ vfpsetup! = 0) or empty (this. selectcmd ))
If Not This. usecursorschema
Cschema = ' '
Ckeyword = ' Select, from, where, order by, having'
Text To Csql
Select < Gcgetsubclause (this. selectcmd, ckeyword, ' Select ')>
From < Gcgetsubclause (this. selectcmd, ckeyword, ' From ')>
Where 1 = 2
Endtext
If Not Glsql ( 0 , Csql)
Select (Narea)
Return . F.
Endif
*- Field category conversion T -> D, g -> W (BLOB)
For I = 1 To Fcount ()
Ctype = Gcfieldtype (I, ' ', 2)
Ctype = Icase ( Left ( Ctype , 1 ) = ' G', 'w ',;
Left ( Ctype , 1 ) = ' T' and (not 'time' $ field (I) and not 'time' $ field (I), 'D '+ substr (ctype, 2 ),;
. T ., Ctype )
If Getwordnum ( Ctype , 1 , ' (,) ') = 'N'
*- Fixed the bug of VFP SP2 beta.
*- N ( 5 ) -> N ( 3 )
*- N ( 5 , 2 ) -> N ( 4 , 2 )
Cdecimal = Getwordnum ( Ctype , 3 , ' (,)')
Clenght = Alltrim ( Str ( Val (Getwordnum ( Ctype , 2 , ' (,) ')-IIF (cdecimal = '0 )))&&
Ctype = ' N ('+ clenght +', '+ cdecimal + ')'
Endif
Cschema = Cschema + ' , '+ Field (I) + ''+ ctype
Next
Cschema = Substr (cschema, 2 )
This. cursorschema=Cschema
This. usecursorschema=. T.
Endif
Endif
*--EOS-----------------------------------------
Select (narea)
(2) Add a method_ C field comparison table, Returns the comparison table of alias. Field and select statement A. XX. It is mostly used in multi-condition generators.
*--- Retrieve A. xx <-> XX table
*- Encounter Select * No matter.
Local CTMP, I, Oca, C table, and CCA field name
Local CCA field name, C Column Title, C field type, C Column Title, CTMP, C front-end field name, nposi, cselect
Cselect = Gcgetsubclause (this. selectcmd, ' Select, from, where, order by ', 'select ')
Cselect = Strtran (cselect, ' Distinct ','')
C comparison table = ' '
For I = 1 To Getwordcount (cselect, ' ,')
CTMP = Alltrim (getwordnum (cselect, I, ' , '), 1, CHR (9), CHR (10), CHR (13), CHR (32 ))
NPOs = ATC ( ' As ', CTMP)
If NPOs = 0
Cfield = CTMP
Ccaption = IIF (( ' . ', CTMP)> 0, getwordnum (CTMP, 2,'. '), CTMP)
Else
Cfield = Alltrim (substr (CTMP, 1 , NPOs - 1 ))
Ccaption = Alltrim (substr (CTMP, NPOs + 2 ))
Endif
C comparison table = C comparison table + ' , '+ Textmerge ("<ccaption >,< cfield >,< type (ccaption)> ")
Next
C comparison table = Substr (C table, 2 )
*--
Return C comparison table