FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour ADO RDD xHarbour
Posts: 838
Joined: Fri Feb 10, 2006 12:14 PM
Re: ADO RDD xHarbour
Posted: Fri Mar 27, 2015 08:13 AM

Antonio,

What is this for ?

HB_SYMBOL_UNUSED( nWA )

Regards

Antonio H Ferreira
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: ADO RDD xHarbour
Posted: Fri Mar 27, 2015 09:37 AM
Antonio,

AHF wrote:Antonio,

What is this for ?

HB_SYMBOL_UNUSED( nWA )


To avoid unused variable warning.

EMG
Posts: 838
Joined: Fri Feb 10, 2006 12:14 PM
Re: ADO RDD xHarbour
Posted: Fri Mar 27, 2015 09:39 AM

Enrico,

Thanks

Regards

Antonio H Ferreira
Posts: 838
Joined: Fri Feb 10, 2006 12:14 PM
Re: ADO RDD xHarbour
Posted: Fri Mar 27, 2015 01:42 PM
Antonio,

Ive made some changes to the function FWAdo... because ws returning wrong types and n decimals.

These replaced the former functions in adordd ADOGETFIELDSIZE AND DOGETFIELDTYPE.

It seems to be correct but Im not sure.

Could you or someone check the code below for some bugs?

There are also some questions marks to answer if someone knows.


Code (fw): Select all Collapse
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 }
Regards

Antonio H Ferreira
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: ADO RDD xHarbour
Posted: Fri Mar 27, 2015 03:45 PM

Antonio,

I am afraid that the only way to really test it is once it becomes used by several Harbour/xharbour users

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 838
Joined: Fri Feb 10, 2006 12:14 PM
Re: ADO RDD xHarbour
Posted: Fri Mar 27, 2015 04:10 PM

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.

Regards

Antonio H Ferreira
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: ADO RDD xHarbour
Posted: Fri Mar 27, 2015 04:14 PM

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 ?

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: ADO RDD xHarbour
Posted: Fri Mar 27, 2015 04:19 PM
Antonio,

AHF wrote:Do you code code use index present in the server DB with ADOX? Maybe Enrico has it.


No, I prefer to use WHERE and ORDER BY clauses.

EMG
Posts: 838
Joined: Fri Feb 10, 2006 12:14 PM
Re: ADO RDD xHarbour
Posted: Fri Mar 27, 2015 04:44 PM

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?

Regards

Antonio H Ferreira
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: ADO RDD xHarbour
Posted: Fri Mar 27, 2015 05:33 PM
Antonio,

AHF wrote:I know I shouldnt use ADOX!


Please note that ADOX is only supported by Microsoft databases.

EMG
Posts: 838
Joined: Fri Feb 10, 2006 12:14 PM
Re: ADO RDD xHarbour
Posted: Fri Mar 27, 2015 06:13 PM

Enrico,

Forgot ADOX going into SELECT.

Regards

Antonio H Ferreira
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: ADO RDD xHarbour
Posted: Fri Mar 27, 2015 07:02 PM

Use oRs:Filter instead of WHERE, so setting oRs:Filter := "" will make have you have all of them when you need them

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Posts: 838
Joined: Fri Feb 10, 2006 12:14 PM
Re: ADO RDD xHarbour
Posted: Fri Mar 27, 2015 07:29 PM

Antonio,

Thanks but it seems filter its not advisable and compatible with all providers.

Ill give a try with selects

Regards

Antonio H Ferreira
Posts: 838
Joined: Fri Feb 10, 2006 12:14 PM
Re: ADO RDD xHarbour
Posted: Fri Mar 27, 2015 08:02 PM

Antonio,

In ADO_OPEN we load all fieldinfo UR_SUPER_ADDFIELD( nWA, aField ).

How can we get back after the information save there?

Regards

Antonio H Ferreira