ADO RDD xHarbour

Re: ADO RDD xHarbour

Postby lucasdebeltran » Fri May 22, 2015 11:08 am

Antonio,

Sorry, I don´t understand.

We have to check it at FUNCTION ADOSTRUCTTOSQL().

If the programmer has indicated in aStruct the autoincremental field, it´s perfect, nothing to be done.

Otherwhise:

Code: Select all  Expand view
if aAcan( aStruct, ADODEFLDRECNO() ) = 0
  AIns( aCols, 1, {  ADODEFLDRECNO(), '+', 10, 0 }, .t. )
endif
 


That´s it.
Muchas gracias. Many thanks.

Un saludo, Best regards,

Harbour 3.2.0dev, Borland C++ 5.82 y FWH 13.06 [producción]

Implementando MSVC 2010, FWH64 y ADO.

Abandonando uso xHarbour y SQLRDD.
User avatar
lucasdebeltran
 
Posts: 1303
Joined: Tue Jul 21, 2009 8:12 am

Re: ADO RDD xHarbour

Postby AHF » Fri May 22, 2015 1:38 pm

Lucas,

This is in ado_open() for next fields

Code: Select all  Expand view

      IF ADO_FIELDSTRUCT( oRecordSet, n-1 )[2] = "+" //OUR FIELD RECNO CAN ONLY BE ONE PER TABLE ITS ALREADY DEFINED USE IT
         aWAData[WA_FIELDRECNO]:=  n - 1
         //IF IT SUPPORTS SEEK WE WILL SEEK IT ISNTEAD OF FIND IT
         IF !oRecordSet:Supports(adIndex) .OR. !oRecordSet:Supports(adSeek)
            //OTHERWISE LETS USE ADO INDEX PROP TO SPEED UP
            IF  oRecordSet:CursorLocation = adUseClient 
                oRecordSet:Fields( aWAData[WA_FIELDRECNO] ):Properties():Item("Optimize"):Value := 1
            ENDIF
           
         ENDIF 
         
      ENDIF

 


Outside the next:

Code: Select all  Expand view

IF EMPTY(aWAData[WA_FIELDRECNO]) //DONT HAVE ANY AUTO INC FIELD USE AS RECNO CREATE
   
      IF ! EMPTY(ADO_GET_FIELD_RECNO(  aWAData[ WA_TABLENAME ] ))
     
         cName := "ALTER TABLE "+ aWAData[ WA_TABLENAME ]+" ADD "+ ADO_GET_FIELD_RECNO(  aWAData[ WA_TABLENAME ] )
         
         cName += HB_DECODE( aWAData[ WA_ENGINE ],  "DBASE", "","ACCESS"," AUTOINCREMENT","MSSQL"," INT IDENTITY( 1, 1 )",;
                     "MYSQL", " INT AUTO_INCREMENT","ORACLE"," INT","SQLITE"," INTEGER","FOXPRO"," NUMERIC",;
                     "POSTGRE"," SERIAL","INFORMIX"," SERIAL","ANYWHERE"," INTEGER IDENTITY","ADS"," AUTOINC", )
         
         IF aWAData[ WA_ENGINE ] <> "ADS"
            cName  += ", ADD PRIMARY KEY "+ADO_GET_FIELD_RECNO(  aWAData[ WA_TABLENAME ])
         ENDIF 
         
         TRY
         
            aWAData[ WA_CONNECTION ]:execute(cName)
         
            aField[ UR_FI_NAME ]    := ADO_GET_FIELD_RECNO(  aWAData[ WA_TABLENAME ])
            aField[ UR_FI_TYPE ]    := HB_FT_AUTOINC
            aField[ UR_FI_TYPEEXT ] := 0
            aField[ UR_FI_LEN ]     := 10
            aField[ UR_FI_DEC ]     := 0
         
            UR_SUPER_ADDFIELD( nWA, aField )
           
            aWAData[WA_FIELDRECNO] := ADO_GET_FIELD_RECNO(  aWAData[ WA_TABLENAME ])
           
            IF !oRecordSet:Supports(adIndex) .OR. !oRecordSet:Supports(adSeek)
               //OTHERWISE LETS USE ADO INDEX PROP TO SPEED UP
               IF  oRecordSet:CursorLocation = adUseClient   
                   oRecordSet:Fields( aWAData[WA_FIELDRECNO] ):Properties():Item("Optimize"):Value := 1
               ENDIF
            ENDIF   

         CATCH
            aWAData[WA_FIELDRECNO] := NIL
           // ADOSHOWERROR(aWAData[ WA_CONNECTION ])
         END
         
      ENDIF
     
   ENDIF
 
Regards
Antonio H Ferreira
AHF
 
Posts: 838
Joined: Fri Feb 10, 2006 12:14 pm

Re: ADO RDD xHarbour

Postby AHF » Fri May 22, 2015 4:21 pm

adordd its working quite well but still some adjustments to do. (MySql)

Our client is working with the app with adordd in MySql in parallel with the same app with ADS comparing all transactions and behavior between the two. He s quit happy. (2nd week trials on real data)

The app its more than 90% converted ( tested ) and we only needed to change till now a couple of index create expressions and like this:

Code: Select all  Expand view

     IF RDDNAME() == "ADORDD"
        cexpress := "CONVERT(ano,UNSIGNED)*100+CONVERT(sementrega,UNSIGNED) >=" +semanaini+" and "+ ;
                    "CONVERT(ano,UNSIGNED)*100+CONVERT(sementrega,UNSIGNED) <= "+semanafim+ ;
                    " and nrfactur = '         '"
     ELSE                  
     cexpress := "val(ano)*100+val(sementrega) >=val('"+str(semanaini)+"') .and."+ ;
               "val(ano)*100+val(sementrega) <= val('"+str(semanafim)+"')"+ ;
               ".and. nrfactur == space(10)"
     ENDIF
 



The only true complaint till now is the speed problem with dbeval() mainly in SUM operations. Its really very
slow and we cant find out why! Antonio any ideas?

Meanwhile we found that in certain SELECT.. WHERE... field properties become inaccessible even when recordset its not empty. Add records its not possible.
Fortunately we only need it for autoinc property and we found a workaround.
Maybe Mr.Rao knows the reason for it.

Our client has its own filter routines either already through SELECTS or by filing arrays so its not important to us nevertheless because will certainly be important for the market in general Im checking with Lucas a workaround to make it 100% compatible with (x)Harbour syntax.
Any contribution is most welcome!

Now it seems that we have more 2 clients interested in porting apps to SQL. (one MySql other Oracle) :D

Please note that adordd its only being tested with ADS oledb, ACCESS and MySql.

I expect to post a new version today's evening or tomorrow morning.

Letting (x)Harbour to navigate freely around all data. :D
Regards
Antonio H Ferreira
AHF
 
Posts: 838
Joined: Fri Feb 10, 2006 12:14 pm

Re: ADO RDD xHarbour

Postby lucasdebeltran » Fri May 22, 2015 4:58 pm

Antonio,

I am also having trouble with MySQL.

For somehow, at ADOFINDREC() oRecordSet:AbsolutePosition := IF( oRS:AbsolutePosition == adPosEOF, oRS:RecordCount() + 1, oRS:AbsolutePosition )

is set to -1, and it gives an error.

oRecordSet:AbsolutePosition can´t be minor than 0.

Do yoy know why?

Thank you.
Muchas gracias. Many thanks.

Un saludo, Best regards,

Harbour 3.2.0dev, Borland C++ 5.82 y FWH 13.06 [producción]

Implementando MSVC 2010, FWH64 y ADO.

Abandonando uso xHarbour y SQLRDD.
User avatar
lucasdebeltran
 
Posts: 1303
Joined: Tue Jul 21, 2009 8:12 am

Re: ADO RDD xHarbour

Postby AHF » Fri May 22, 2015 5:05 pm

Lucas,

You don't have recno field and your cursor doesn't support bookmarks.

Please note that although the code foresee a situation where you don't have hbrenco results would be unpredictable in some circumstances.

If you are using version sent by last email when you opened this table it should have created the hbrecno field . Please check.
Regards
Antonio H Ferreira
AHF
 
Posts: 838
Joined: Fri Feb 10, 2006 12:14 pm

Re: ADO RDD xHarbour

Postby lucasdebeltran » Fri May 22, 2015 5:09 pm

Antonio,

Yes, I do have HBRECNO and I am using your code.

In fact, at ADO_OPEN( nWA, aOpenInfo ), you added :

IF EMPTY(aWAData[WA_FIELDRECNO]) //DONT HAVE ANY AUTO INC FIELD USE AS RECNO CREATE
....


Well, despite I have HBRECNO, aWAData[WA_FIELDRECNO is giving 0.

Also, the sintax for ALTER TABLE is failing too.
Muchas gracias. Many thanks.

Un saludo, Best regards,

Harbour 3.2.0dev, Borland C++ 5.82 y FWH 13.06 [producción]

Implementando MSVC 2010, FWH64 y ADO.

Abandonando uso xHarbour y SQLRDD.
User avatar
lucasdebeltran
 
Posts: 1303
Joined: Tue Jul 21, 2009 8:12 am

Re: ADO RDD xHarbour

Postby AHF » Fri May 22, 2015 5:19 pm

Lucas,

If it is the first field can be 0!

Might be a bug.
In all our tables its always the last field and I suspect that with zero IF EMPTY(aWAData[WA_FIELDRECNO]) rerturns .t..

Please try delete hbrecno and add it to the end of all fields.
Regards
Antonio H Ferreira
AHF
 
Posts: 838
Joined: Fri Feb 10, 2006 12:14 pm

Re: ADO RDD xHarbour

Postby lucasdebeltran » Fri May 22, 2015 5:34 pm

Antonio,

Another bug in ADO_APPEND() and MySQL.

Dates are not saved into aVals, so oRs:AddNew( aCols, aVals ) fails.

Also maybe a problem with empty dates?.
Muchas gracias. Many thanks.

Un saludo, Best regards,

Harbour 3.2.0dev, Borland C++ 5.82 y FWH 13.06 [producción]

Implementando MSVC 2010, FWH64 y ADO.

Abandonando uso xHarbour y SQLRDD.
User avatar
lucasdebeltran
 
Posts: 1303
Joined: Tue Jul 21, 2009 8:12 am

Re: ADO RDD xHarbour

Postby lucasdebeltran » Fri May 22, 2015 5:50 pm

Antonio,

Please try delete hbrecno and add it to the end of all fields.


Yes, in that case works, but I think HBRECNO should be the first field, also as the PRIMARY KEY.

Thank you.
Muchas gracias. Many thanks.

Un saludo, Best regards,

Harbour 3.2.0dev, Borland C++ 5.82 y FWH 13.06 [producción]

Implementando MSVC 2010, FWH64 y ADO.

Abandonando uso xHarbour y SQLRDD.
User avatar
lucasdebeltran
 
Posts: 1303
Joined: Tue Jul 21, 2009 8:12 am

Re: ADO RDD xHarbour

Postby AHF » Fri May 22, 2015 6:01 pm

Lucas,

Another bug in ADO_APPEND() and MySQL.

Dates are not saved into aVals, so oRs:AddNew( aCols, aVals ) fails.

Also maybe a problem with empty dates?.


Here working ok.

Code: Select all  Expand view

append blank
replace datefield with date()
 


Can you post a example?
Regards
Antonio H Ferreira
AHF
 
Posts: 838
Joined: Fri Feb 10, 2006 12:14 pm

Re: ADO RDD xHarbour

Postby lucasdebeltran » Fri May 22, 2015 6:20 pm

Antonio,

It´s with MySQL.

At ADO_APPEND, i checked aVals and date fields very empty.

Are you testing with Access or MySQL?.

With ACCESS Works fine.
Muchas gracias. Many thanks.

Un saludo, Best regards,

Harbour 3.2.0dev, Borland C++ 5.82 y FWH 13.06 [producción]

Implementando MSVC 2010, FWH64 y ADO.

Abandonando uso xHarbour y SQLRDD.
User avatar
lucasdebeltran
 
Posts: 1303
Joined: Tue Jul 21, 2009 8:12 am

Re: ADO RDD xHarbour

Postby AHF » Fri May 22, 2015 6:22 pm

Lucas,

MySql and its working ok.
Regards
Antonio H Ferreira
AHF
 
Posts: 838
Joined: Fri Feb 10, 2006 12:14 pm

Re: ADO RDD xHarbour

Postby AHF » Sat May 23, 2015 7:33 am

lucasdebeltran wrote:Antonio,

It´s with MySQL.

At ADO_APPEND, i checked aVals and date fields very empty.

Are you testing with Access or MySQL?.

With ACCESS Works fine.


This might be due to not nullable fields defined in MySql table structure.
Regards
Antonio H Ferreira
AHF
 
Posts: 838
Joined: Fri Feb 10, 2006 12:14 pm

Re: ADO RDD xHarbour

Postby AHF » Sat May 23, 2015 7:42 am

Lucas,

Basic :filter ready.

Please note that expressions like '.. month(fielddate) =' are invalid.
We cant use functions in field expressions.

The only way to use standard filter expressions is like in the mail Ive sent you.
I don't see any other way.

Concerning add column in first position to use as recno please note that as far as I discover that is only possible in MySql and Oracle other RMBDs do not allow it.

Testing EMPTY( ..[ WA_FIELDRECNO] ) changed to !VALTYPE( ..[ WA_FIELDRECNO] ) == "U" because if field in first column value would be zero and empty true.
Regards
Antonio H Ferreira
AHF
 
Posts: 838
Joined: Fri Feb 10, 2006 12:14 pm

Re: ADO RDD xHarbour

Postby lucasdebeltran » Sat May 23, 2015 8:34 am

Antonio,

No, the replace is as follows:

REPLACE FIELD->FECHA WITH Date().

Here is MySQL capture:

Image

About filtering, I don´t understand. ADORDD should be able to support filters like those ones:

Code: Select all  Expand view

  cCondicion := "Dtoc( FIELD->FECHA ) >= " + chr( 34 ) + Dtoc( dFecha1 ) + chr( 34 ) + ;
                " .AND. Dtoc( FIELD->FECHA ) <= " + chr( 34 ) + Dtoc( dFecha2 ) + chr( 34 )



  SET FILTER TO alltrim(  AUXILIAR->RELACION  ) == alltrim(  STR( oData:Codigo ))


  cCondicion := "CONTA->CONCEPTO = " + chr( 34 ) + alltrim( cValToChar( cCuentaoConcepto ) ) + chr( 34 )

 



Maybe Antonio, Nages, Enrico or Rick can help us to achieve it.

Thank you.


I think it´s possible to translate them to ADO oRs:Filter().
Muchas gracias. Many thanks.

Un saludo, Best regards,

Harbour 3.2.0dev, Borland C++ 5.82 y FWH 13.06 [producción]

Implementando MSVC 2010, FWH64 y ADO.

Abandonando uso xHarbour y SQLRDD.
User avatar
lucasdebeltran
 
Posts: 1303
Joined: Tue Jul 21, 2009 8:12 am

PreviousNext

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 63 guests