Antonio,
What is this for ?
HB_SYMBOL_UNUSED( nWA )
Antonio H Ferreira
Antonio,
What is this for ?
HB_SYMBOL_UNUSED( nWA )
AHF wrote:Antonio,
What is this for ?
HB_SYMBOL_UNUSED( nWA )
Enrico,
Thanks
STATIC FUNCTION ADO_FIELDSTRUCT( oRs, n ) // ( oRs, nFld ) where nFld is 1 based
// ( oRs, oField ) or ( oRs, cFldName )
// ( oField )
LOCAL oField, nType, uval
LOCAL cType := 'C', nLen := 10, nDec := 0, lRW := .t.,nDBFFieldType := HB_FT_STRING // default
LOCAL nFWAdoMemoSizeThreshold := 1024
/*
cType DBF TYPE "C","N","D" ETC
nDBFFieldType HB_FT_STRING ETC
*/
/* IF n == nil
oField := oRs
oRs := nil
ELSEIF VALTYPE( n ) == 'O'
oField := n
ELSE
IF ValType( n ) == 'N'
n--
ENDIF
TRY
oField := oRs:Fields( n )
CATCH
END
ENDIF
IF oField == nil
RETURN nil
ENDIF
*/
oField := oRs:Fields( n )
nType := oField:Type
IF nType == adBoolean
cType := 'L'
nLen := 1
nDBFFieldType := HB_FT_LOGICAL
ELSEIF ASCAN( { adDate, adDBDate, adDBTime, adDBTimeStamp }, nType ) > 0
cType := 'D'
nLen := 8
IF oRs != nil .AND. ! oRs:Eof() .AND. VALTYPE( uVal := oField:Value ) == 'T'
//.AND. FW_TIMEPART( uVal ) >= 1.0 WHERE IS THIS FUNCTION?
cType := '@' //'T'
nLen := oField:DefinedSize
nDBFFieldType := HB_FT_TIMESTAMP // DONT KNWO IF IT IS CORRECT!
ELSE
nDBFFieldType := HB_FT_DATE
ENDIF
ELSEIF ASCAN( { adTinyInt, adSmallInt, adInteger, adBigInt, ;
adUnsignedTinyInt, adUnsignedSmallInt, adUnsignedInt, ;
adUnsignedBigInt }, nType ) > 0
cType := 'N'
nLen := oField:Precision + 1 // added 1 for - symbol
IF oField:Properties( "ISAUTOINCREMENT" ):Value == .t.
cType := '+'
lRW := .f.
ENDIF
nDBFFieldType := HB_FT_INTEGER
ELSEIF ASCAN( { adSingle, adDouble, adCurrency }, nType ) > 0
cType := 'N' //SHOULDNT BE "B"?
nLen := MIN( 19, oField:Precision-oField:NumericScale-1 ) //+ 2 )
IF oField:NumericScale > 0 .AND. oField:NumericScale < nLen
nDec := oField:NumericScale
ENDIF
nDBFFieldType := HB_FT_INTEGER //HB_FT_DOUBLE WICH ONE IS CORRECT?
ELSEIF ASCAN( { adDecimal, adNumeric, adVarNumeric }, nType ) > 0
cType := 'N'
nLen := Min( 19, oField:Precision-oField:NumericScale-1 ) //+ 2 )
IF oField:NumericScale > 0 .AND. oField:NumericScale < nLen
nDec := oField:NumericScale
ENDIF
nDBFFieldType := HB_FT_INTEGER //HB_FT_LONG WICH ONE IS CORRECT?
ELSEIF ASCAN( { adBSTR, adChar, adVarChar, adLongVarChar, adWChar, adVarWChar, adLongVarWChar }, nType ) > 0
nLen := oField:DefinedSize
nDBFFieldType := HB_FT_STRING
IF nType != adChar .AND. nType != adWChar .AND. nLen > nFWAdoMemoSizeThreshold
cType := 'M'
nLen := 10
nDBFFieldType := HB_FT_MEMO
ENDIF
ELSEIF ASCAN( { adBinary, adVarBinary, adLongVarBinary }, nType ) > 0
cType := "G"
nLen := oField:DefinedSize
IF nType != adBinary .AND. nLen > nFWAdoMemoSizeThreshold
cType := 'M'
nLen := 10
ENDIF
nDBFFieldType := HB_FT_OLE
IF nType != adBinary .AND. nLen > nFWAdoMemoSizeThreshold
nDBFFieldType := HB_FT_MEMO
ENDIF
ELSEIF ASCAN( { adChapter, adPropVariant}, nType ) > 0
cType := 'O'
lRW := .f.
nDBFFieldType := HB_FT_MEMO
ELSEIF ASCAN( { adVariant, adIUnknown }, nType ) > 0
cType := "V"
nDBFFieldType := HB_FT_ANY
ELSEIF ASCAN( { adGUID }, nType ) > 0
nDBFFieldType := HB_FT_STRING
ELSEIF ASCAN( { adFileTime }, nType ) > 0
cType := "T"
nDBFFieldType := HB_FT_DATETIME
ELSEIF ASCAN( { adEmpty, adError, adUserDefined, adIDispatch }, nType ) > 0
cType = 'O'
lRw := .t.
nDBFFieldType := HB_FT_NONE //what is this? maybe NONE is wrong!
ELSE
lRW := .f.
ENDIF
IF lAnd( oField:Attributes, 0x72100 ) .OR. ! lAnd( oField:Attributes, 8 )
lRW := .f.
ENDIF
RETURN { oField:Name, cType, nLen, nDec, nType, lRW, nDBFFieldType }Antonio,
I am afraid that the only way to really test it is once it becomes used by several Harbour/xharbour users
Antonio,
What I dont understad is what type of fields we must return to SUPER!
Is it only STRING, DATE, LOGICAL, DOUBLE OR INTEGER as in arrayrdd?
Im now taking care of :Seek but I need to use DB indexes. Seek cannot be translated to :Find as :Find only works on a single column.
Do you code code use index present in the server DB with ADOX? Maybe Enrico has it.
Im only missing this to close the first part of adodrdd
I hope to post during week end the adordd.
Antonio,
Yes, you can only return the types that Harbour supports.
What if you issue a new SELECT clause with the WHERE conditions that you are searching for ?
AHF wrote:Do you code code use index present in the server DB with ADOX? Maybe Enrico has it.
Antonio, Enrico,
I know I shouldnt use ADOX!
I agree is the best practice. Indexes are for the DB admin to deliver selects rapidly.
But dont forget that what we pretend is to change as little code as possible in our app.
I could use seek but then I would have to call a resetseek() to come back to the previous select. Doesnt seems a huge work.
But if I need to add blanck recs to the select to come back later for update I would not found them because they still dont fill the select where clause.This is a problem! Maybe using a diferent cursor?
Do you have any idea how to workaround this?
AHF wrote:I know I shouldnt use ADOX!
Enrico,
Forgot ADOX going into SELECT.
Use oRs:Filter instead of WHERE, so setting oRs:Filter := "" will make have you have all of them when you need them
Antonio,
Thanks but it seems filter its not advisable and compatible with all providers.
Ill give a try with selects
Antonio,
In ADO_OPEN we load all fieldinfo UR_SUPER_ADDFIELD( nWA, aField ).
How can we get back after the information save there?