Page 1 of 3

Incluyendo el SQLRDD

PostPosted: Wed Aug 16, 2023 9:47 pm
by jair
Buenas tardes a todos.

Para aquellos que aún no lo han visto, todas las fuentes en xharbour.com son de código abierto. Intenté compilar pero no pude porque tengo poca experiencia en compilar fuentes de xharbour. Si alguien me puede ayudar creo que sería muy interesante que alguien que tenga conocimiento compile el código fuente sqlrdd que hace posible usar una base de datos sql y otras de la misma forma que se usa un archivo dbf. Estaré inmensamente agradecido si alguien logra armar un script que compile este sqlrdd.

Incluyendo el SQLRDD
https://github.com/ronpinkas/xharbour/t ... our-SQLRDD


no poder compilar solo 6 archivos que usan include y no poder ubicar este archivo al que se hace referencia en el include.

Re: Incluyendo el SQLRDD

PostPosted: Thu Aug 17, 2023 3:49 am
by carlos vargas
Yo compile el sqlrdd de los fuentes para xharbour y bcc 7.6, para lograrlo debes instalar bison, por qué sqlrdd parsea las instrucciones SQL, además debes usar hbmk2 de harbour con la opción -xhb y usar el sqlrdd.hbp, hay un bat el cual debes revisar la cual define un variable de entorno que define la ruta de bison.

Re: Incluyendo el SQLRDD

PostPosted: Sat Aug 19, 2023 4:20 am
by Antonio Linares
Querido Carlos,

Puedes compartir el SQLRDD que has construido para Harbour ? Podemos tenerlo para bcc, msvc y gcc ? En 32 y 64 bits.

Que tal su funcionamiento con Harbour ? Lo has probado ? Que puedes comentarnos al respecto ?

muchas gracias por tu gran ayuda

Re: Incluyendo el SQLRDD

PostPosted: Sat Aug 19, 2023 11:48 am
by Joaquim Ferrer
Buenos dias

He conseguido construir sqlrdd.lib para harbour con BCC 5.8 y BCC 7.0, siguiendo las amables instrucciones de Carlos, pero con varias modificaciones :

Los *.prg sqlodbf, sqlmy, sqlpgs, sqlfirebird y sqloracle he tenido que cambiar todas las llamadas Super: por ::Super:

He incluido como menciona Carlos el flag -xhb tanto en línea como dentro del script, pero seguía sin funcionar si no aplico el cambio anterior

Este es mi entorno :
Code: Select all  Expand view

PATH=%PATH%;c:\borland\bcc70\bin;c:\hb32\bin;C:\GnuWin32\bin
set compiler=bcc
set include=C:\xhb\include;C:\xhbcore\xharbour\include;c:\hbcore\contrib\xhb
 


Y la instrucción en linea :

Code: Select all  Expand view
c:\hb32\bin\hbmk2 -xhb sqlrdd.hbp


Saludos

Re: Incluyendo el SQLRDD

PostPosted: Sat Aug 19, 2023 4:29 pm
by paquitohm
Hola

¿ Podría alguien poner una descarga a la .lib generada de sqlrdd y los .ch y otros necesarios para asi poder probarlo en un momento ?

Gracias

Re: Incluyendo el SQLRDD

PostPosted: Sat Aug 19, 2023 9:13 pm
by mgsoft
Hola,

¿Es la versión que vendían en xharbour?

Saludos

Re: Incluyendo el SQLRDD

PostPosted: Sun Aug 20, 2023 8:31 am
by Joaquim Ferrer
Buenos dias

Despues de construir la lib sqlrdd para harbour, sigue el reto de construir un test de funcionalidades...

Creo va a ser difícil -almenos para mi- obtener compatibilidad ya que no se encuentran funciones del core de xharbour, portadas al core de harbour

Por ejemplo, hb_stordtl que es de la vm/extend.c de xharbour no existe en harbour https://github.com/harbour/core
o tambien hb_dateTimeStampStrGet, localizada en common\hbdate.c

Esto es lo que falla al construir samples/demo01.prg
Code: Select all  Expand view

Error: Unresolved external '_HB_IS_TIMEFLAG' referenced from C:\DEV\SQLRDD\LIB\SQLRDD.LIB|sqlrdd1
Error: Unresolved external 'SQLInstallerError' referenced from C:\DEV\SQLRDD\LIB\SQLRDD.LIB|sqlsrodbc
Error: Unresolved external 'SQLConfigDataSource' referenced from C:\DEV\SQLRDD\LIB\SQLRDD.LIB|sqlsrodbc
Error: Unresolved external '_hb_dateTimeStampStrGet' referenced from C:\DEV\SQLRDD\LIB\SQLRDD.LIB|sqlsrodbc
Error: Unresolved external '_hb_timeEncStr' referenced from C:\DEV\SQLRDD\LIB\SQLRDD.LIB|pgs
Error: Unresolved external '_hb_stordtl' referenced from C:\DEV\SQLRDD\LIB\SQLRDD.LIB|firebird
 

Este es mi fichero de proyecto
Code: Select all  Expand view

# test
#

-n -q0 -static

#Includes
-I.\include
-L.\lib

xhb.hbc
hbodbc.hbc

#libs
-lsqlrdd
-llibmysql
-lfbclient
-lfbclient_bc
-llibpq
-loci
-lodbccp32

-otest

prg\connect.prg
prg\demo01.prg
 

He creado un repositorio público por si alguien quiere probar
https://github.com/QuimFerrer/sqlrdd

De momento no veo la forma de que sqlrdd funcione para harbour, a ver si algún gurú nos ilumina

Saludos

Re: Incluyendo el SQLRDD

PostPosted: Sun Aug 20, 2023 10:58 am
by Antonio Linares
mgsoft wrote:Hola,

¿Es la versión que vendían en xharbour?

Saludos


si

Re: Incluyendo el SQLRDD

PostPosted: Tue Aug 22, 2023 10:05 pm
by jair
https://github.com/marcosgambeta/sqlrddpp/tree/main
Ahora ya disponemos de una versión adaptada para puerto

cd sqlrddpp
hbmk2 sqlrddpp.hbp

Re: Incluyendo el SQLRDD

PostPosted: Wed Aug 23, 2023 7:51 am
by Joaquim Ferrer
Buenos dias

Muchas gracias por el aporte Jair y por el esfuerzo de Marcelo Lombardo

He construido sqlrddpp.lib sin problemas, pero al intentar construir un test de ejemplo, siguen fallando estas 2 funciones
Code: Select all  Expand view

Turbo Incremental Link 6.70 Copyright (c) 1997-2014 Embarcadero Technologies, Inc.
Error: Unresolved external 'SQLInstallerError' referenced from C:\DEV\SQLRDD\LIB\SQLRDDPP.LIB|sqlsrodbc
Error: Unresolved external 'SQLConfigDataSource' referenced from C:\DEV\SQLRDD\LIB\SQLRDDPP.LIB|sqlsrodbc
Error: Unable to perform link
 


Entiendo que estas 2 funciones son de la implementación ODBC 3.0
https://learn.microsoft.com/en-us/sql/odbc/reference/syntax/sqlinstallererror-function?view=fabric

pero no las encuentro implementadas en odbc.c ni en el core de xharbour ni en las contrib de harbour

A ver si puedo superar esto y seguir, gracias !

Re: Incluyendo el SQLRDD

PostPosted: Wed Aug 23, 2023 8:34 am
by Antonio Linares
Estimado Joaquim,

Prueba a enlazar odbccp32.lib, viene con el compilador de C que estés usando

Re: Incluyendo el SQLRDD

PostPosted: Wed Aug 23, 2023 10:30 am
by Joaquim Ferrer
Querido Antonio

Gracias por responder... aunque sí estaba enlazando odbccp32.lib, en mi C:\borland\BCC70\lib\psdk\ dicha lib estaba incompleta

La he sustituido por la que proporcionan en sqlrddpp\lib\BC5\ y listo, ha funcionado a la primera

He construido mi exe de test y ahora toca pelearse con las cadenas de conexión
Code: Select all  Expand view

Small SQLRDD demo
(c) 2003 - Marcelo Lombardo

Connecting to database...
Connected to        : MYSQL NATIVE 50505
RDD in use          : SQLRDD
Error SQLRDD/1001  Error Opening table in SQL database - RollBack executed.: AGENCIAS (DOS Error 2)
Called from SR_WORKAREA:RUNTIMEERR(1942)
Called from SR_WORKAREA:SQLOPENAREA(5962)
Called from DBUSEAREA(0)
Called from MAIN(52)
 


A ver hasta donde llego, ya queda poco :)

Re: Incluyendo el SQLRDD

PostPosted: Wed Aug 23, 2023 11:47 am
by Antonio Linares
muy bien :-D

Re: Incluyendo el SQLRDD

PostPosted: Thu Aug 24, 2023 8:10 am
by Joaquim Ferrer
Buenos dias

Sigo avanzando, pero con algunas curiosidades ...

Con el pequeño ejemplo adjunto, he conseguido listar las tablas de una BD, saber si una tabla existe o crear una tabla y añadirle registros

El caso curioso es que me da error al abrir una tabla existente en la BD, que no ha creado directamente SQLRDD
Code: Select all  Expand view

Error SQLRDD/1001  Error Opening table in SQL database - RollBack executed.: TEST2 (DOS Error 2)
Called from SR_WORKAREA:RUNTIMEERR(1942)
Called from SR_WORKAREA:SQLOPENAREA(5962)
Called from DBUSEAREA(0)
Called from CREATETABLE(97)
Called from MAIN(72)
 

He comparado la creación de una tabla, por ejemplo desde HeidiSQL con la que crea SQLRDD y no le veo diferencias( permisos, codepage, etc)

También como curiosidad, los campos extendidos de las DBF, por ejemplo los autoincrementales {"ID", "+", 10,0 } producen error al ejecutar DbCreate(), PERO la buena noticia es que SQLRDD nos crea un campo autoincremental de forma automática, con su indice de clave primaria

Aqui dejo mi ejemplo, por si alguien quiere experimentar y contrastar lo que explico

Code: Select all  Expand view

/*
* SQLRDD Test
* Copyright (c) 2003 - Marcelo Lombardo  <marcelo@xharbour.com.br>
* All Rights Reserved
*/


#include "sqlrdd.ch"

#define RECORDS_IN_TEST                   1000
#define SQL_DBMS_NAME                       17
#define SQL_DBMS_VER                        18

REQUEST SQLRDD             // SQLRDD should be linked in
REQUEST SQLEX              // SQLRDD Extreme should be linked in

REQUEST SR_ODBC            // Needed if you plan to connect with ODBC
// REQUEST SR_PGS             // Needed if you plan to use native connection to Postgres
REQUEST SR_MYSQL           // Needed if you plan to use native connection to MySQL
// REQUEST SR_ORACLE          // Needed if you plan to use native connection to Oracle
// REQUEST SR_FIREBIRD        // Needed if you plan to use native connection to Firebird

REQUEST DBFNTX
REQUEST DBFCDX
REQUEST DBFFPT
REQUEST DBFDBT


/*------------------------------------------------------------------------*/

PROCEDURE main()

   local nCnn, i
   local cRDD, cConnString
   local aFiles

   RddSetDefault( "DBFCDX" )

  // Las 2 cadenas funcionan de forma identica
   cConnString := "MySQL=localhost;UID=root;PWD=1234;DTB=testdb"
   cConnString := "Server=localhost; Port=3306; Database=testdb; Uid=root; Pwd=1234;"

   SR_SETSQL2008NEWTYPES(.t.)
   SR_SetMininumVarchar2Size( 2 )
   SR_UseDeleteds(.f.)
   SR_SetlUseDBCatalogs( .T. )    // Utilizar indices de la BD

   ? "Test SQLRDD"
   ? ""
   ? "Connecting to database..."

   cRDD := "SQLRDD"
   nCnn := SR_AddConnection( CONNECT_MYSQL, cConnString )

   ? "Connected to        :", SR_GetConnectionInfo(, SQL_DBMS_NAME ), SR_GetConnectionInfo(, SQL_DBMS_VER )
   ? "RDD Version         :", SR_Version()
   ? "RDD in use          :", cRDD
   ? "ConnectionType      :", SR_GetConnection():nConnectionType

   cTable := "customer"
   ? "Exist Table "+ cTable, SR_ExistTable( cTable )

   aFiles := SR_ListTables("testdb")
   ? "Tablas de la BD     :", len(aFiles)

   ? "Lista de Tablas"
   for each i in aFiles
      // Descartar tablas de sistema
      if ! left( i, 3 ) $ "SR_;TOP;SYS;DTP"
         ? i
      endif
   next

   CreateTable( cRDD )

   // Tablas creadas fuera del RDD fallan, error apertura !
   // USE ( cTable ) VIA cRDD
   // BROWSE()

RETURN

/*------------------------------------------------------------------------*/

PROCEDURE CreateTable( cRDD )
   
   local nArea
   local cTable  := "test2"
   local aStruct := {;
      {"ID",   "N", 10,0 },;
      {"FIRST","C", 40,0 },;
      {"LAST", "C", 40,0 },;
      {"AGE",  "N", 10,0 } ;
   }

   if ! SR_ExistTable( cTable )
      ? "Creating table      :", dbCreate( cTable, aStruct, cRDD )
   endif

   USE ( cTable ) EXCLUSIVE VIA ( cRDD )
   nArea := select()
   ( nArea )->( dbappend() )
   ( nArea )->ID      := 1
   ( nArea )->FIRST   := "Mark"
   ( nArea )->LAST    := "Baley"
   ( nArea )->AGE     := 39
   ( nArea )->( dbgotop() )

   BROWSE()

RETURN

/*------------------------------------------------------------------------*/
 

Re: Incluyendo el SQLRDD

PostPosted: Thu Aug 24, 2023 8:53 am
by Antonio Linares
Que código hay aqui ?

Called from SR_WORKAREA:SQLOPENAREA(5962)