Incluyendo el SQLRDD

Re: Incluyendo el SQLRDD

Postby Joaquim Ferrer » Thu Aug 24, 2023 9:39 am

La linea 5962 llama a RuntimeErr
Code: Select all  Expand view

      If ::LineCount(.F.) == -1
         ::lOpened := .F.
         ::RuntimeErr( "27", SR_Msg(27) , 2, EG_OPEN, ESQLRDD_OPEN )
         Return Self
      EndIf
 


el codigo de LineCount
Code: Select all  Expand view

METHOD LineCount( lMsg ) CLASS SR_WORKAREA

   Local nRet := 0, aRet := {}

   DEFAULT lMsg := .T.

   If ::lISAM

      If nLineCountResult == 0
         Switch ::oSql:nSystemID
         Case SYSTEMID_POSTGR
            ::oSql:exec("SELECT " + SR_DBQUALIFY( ::cRecnoName, SYSTEMID_POSTGR) + " FROM " + ::cQualifiedTableName + " ORDER BY " + SR_DBQUALIFY( ::cRecnoName, ::oSql:nSystemID ) + " DESC LIMIT 1" + iif(::oSql:lComments, " /* Counting Records */", ""), lMsg, .t., @aRet)
            Exit
         Case SYSTEMID_FIREBR
            ::oSql:exec("SELECT gen_id("+::cFileName+",0) FROM RDB$DATABASE", .F., .T., @aRet)
            Exit
         Case SYSTEMID_CACHE
            ::oSql:exec("SELECT TOP 1 " + SR_DBQUALIFY(::cRecnoName, SYSTEMID_CACHE) + " FROM " + ::cOwner + ::cFileName + " ORDER BY " + SR_DBQUALIFY( ::cRecnoName, ::oSql:nSystemID ) + " DESC", lMsg, .t., @aRet)
            Exit
         Default
           ::oSql:exec("SELECT MAX( " + SR_DBQUALIFY( ::cRecnoName, ::oSql:nSystemID ) + " ) FROM " + ::cQualifiedTableName + iif(::oSql:lComments, " /* Counting Records */", ""), lMsg, .t., @aRet)
         End

         If Len(aRet) > 0 .and. valtype(aRet[1,1]) != "N"
           ::oSql:exec("SELECT COUNT( " + SR_DBQUALIFY( ::cRecnoName, ::oSql:nSystemID ) + " ) FROM " + ::cQualifiedTableName + iif(::oSql:lComments, " /* Counting Records */", ""), lMsg, .t., @aRet)
         EndIf

         If Len(aRet) > 0
            ::aInfo[ AINFO_RCOUNT ] := aRet[1,1]
            nRet := aRet[1,1]
         ElseIf ::oSql:nRetCode != SQL_SUCCESS .and. ::oSql:nRetCode != SQL_NO_DATA_FOUND
            nRet := -1     // Error
         EndIf
      Else
         nRet := nLineCountResult
         ::aInfo[ AINFO_RCOUNT ] := nRet
      EndIf
   Else
      nRet := len(::aCache)
   EndIf

   If Empty(nRet)
      ::lEmptyTable           := .T.
      ::aInfo[ AINFO_RECNO ]  := 1
      ::aInfo[ AINFO_RCOUNT ] := 0
      ::aInfo[ AINFO_BOF ]    := .T.
      ::aInfo[ AINFO_EOF ]    := .T.
   EndIf

Return nRet
 


Podria ser que no entrara a la consulta por el tema de ::lISAM, mi base de datos es innoDb, lo que no entiendo es que las tablas creadas con SQLRDD tambien son innoDB y funcionan
Fivewinner desde 1.9, programador PHP y Javascript, PWA & HTML5 evangelista
User avatar
Joaquim Ferrer
 
Posts: 102
Joined: Sat Jan 14, 2012 3:46 pm
Location: Barcelona

Re: Incluyendo el SQLRDD

Postby Joaquim Ferrer » Thu Aug 24, 2023 10:58 am

Si utilizo directamente la consulta, sin USE ... VIA SQLRDD...

Code: Select all  Expand view

   oSql:= SR_GetConnection()
   oSql:Exec("select * from customer",, .T., @aRows )
   ? oSql:GetAffectedRows()

   ? valtype(aRows), len(aRows)
   ? valtype(aRows[1])

   for each a in aRows
      for each i in a
         ?? i
      next
      ?
   next
 


Se muestran correctamente los registros
Code: Select all  Expand view

Taouk               Dockett             24636 Golden Springs Rd       Princeton                     NH51508-620307/05/90 00:00:00.000.F.         27     23300.0000000000000000000000000000000This is a test for record 492

Mario               French              18139 Hewes Street            Williston                     HI28288-220308/08/83 00:00:00.000.T.         46     55300.0000000000000000000000000000000This is a test for record 493

Gary                Beilharz            16861 Abbots Place            Amerspoort                    WI79471-858301/30/91 00:00:00.000.F.         67    144000.0000000000000000000000000000000This is a test for record 494

Guy                 Acker               27636 Broadway                Framingham                    AK84142-806905/20/89 00:00:00.000.T.         48     39300.0000000000000000000000000000000This is a test for record 495

Dickson             Valle               32693 Stonecutter Lane        Kowloon Bay                   AL18415-926307/14/91 00:00:00.000.F.         87     42200.0000000000000000000000000000000This is a test for record 496
 


Otra forma que también funciona :
Code: Select all  Expand view

   dbUseArea( .F., "SQLRDD", "select * from customer", "customer" )
   ? customer->FIRST
   WAIT
   browse()
 


Pero sigue sin funcionar si la tabla no se ha creado desde SQLRDD, la unica forma es la anterior
Code: Select all  Expand view

USE "customer" NEW VIA "SQLRDD"
 
Fivewinner desde 1.9, programador PHP y Javascript, PWA & HTML5 evangelista
User avatar
Joaquim Ferrer
 
Posts: 102
Joined: Sat Jan 14, 2012 3:46 pm
Location: Barcelona

Re: Incluyendo el SQLRDD

Postby Joaquim Ferrer » Thu Aug 24, 2023 11:42 am

Descubierto el misterio ...

Si queremos abrir una tabla con USE cTable VIA SQLRDD, que no haya sido creada con el RDD, tendremos que modificar la estructura y añadir un campo en dicha tabla
Code: Select all  Expand view

    `sr_recno` BIGINT(20) NOT NULL AUTO_INCREMENT, UNIQUE INDEX `sr_recno` (`sr_recno`) USING BTREE
 


Las tablas creadas por SQLRDD via dbCreate(...) ya añaden de forma automática sr_recno, como he mencionado anteriormente, por lo que no fallará USE cTable VIA SQLRDD

Si no se desea modificar la estructura, siempre se puede utilizar dbUseArea( .F., "SQLRDD", "select * from customer", "customer" )

En conclusión, si se pretende migrar todo un sistema de tablas DBF a una BD SQL es mejor crear las tablas con DbCreate utilizando SQLRDD y posteriormente añadir los registros

Entendiendo un poco como funciona SQLRDD, creo que puede ser realidad el paso de paradigma DBF a SQL
sin tocar una línea de código
... veremos :)
Fivewinner desde 1.9, programador PHP y Javascript, PWA & HTML5 evangelista
User avatar
Joaquim Ferrer
 
Posts: 102
Joined: Sat Jan 14, 2012 3:46 pm
Location: Barcelona

Re: Incluyendo el SQLRDD

Postby Antonio Linares » Thu Aug 24, 2023 12:44 pm

Excellente !!! :-D
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Incluyendo el SQLRDD

Postby Carles » Thu Aug 24, 2023 2:39 pm

Quim

Joaquim Ferrer wrote:Descubierto el misterio ...


Las frescas noches de verano te ayudan a resolver.... :lol:

Congratulations.
C.
Salutacions, saludos, regards

"...programar es fácil, hacer programas es difícil..."

UT Page -> https://carles9000.github.io/
Forum UT -> https://discord.gg/bq8a9yGMWh
Skype -> https://join.skype.com/cnzQg3Kr1dnk
User avatar
Carles
 
Posts: 1090
Joined: Fri Feb 10, 2006 2:34 pm
Location: Barcelona

Re: Incluyendo el SQLRDD

Postby Joaquim Ferrer » Thu Aug 24, 2023 3:35 pm

Gràcies Carles !!!

Como dijo aquel... las neuronas estan fritas, pero la barbacoa está rica :)
Fivewinner desde 1.9, programador PHP y Javascript, PWA & HTML5 evangelista
User avatar
Joaquim Ferrer
 
Posts: 102
Joined: Sat Jan 14, 2012 3:46 pm
Location: Barcelona

Re: Incluyendo el SQLRDD

Postby wilsongamboa » Thu Aug 24, 2023 4:15 pm

Joaquim buenos dias
podrias actualizar https://github.com/QuimFerrer/sqlrdd.git por favor con tus avances
gracias por tu ayuda
Wilson 'W' Gamboa A
Wilson.josenet@gmail.com
User avatar
wilsongamboa
 
Posts: 548
Joined: Wed Oct 19, 2005 6:41 pm
Location: Quito - Ecuador

Re: Incluyendo el SQLRDD

Postby Joaquim Ferrer » Thu Aug 24, 2023 5:02 pm

Repositorio actualizado !

Estaria bien compartir experiencias :)

wilsongamboa wrote:Joaquim buenos dias
podrias actualizar https://github.com/QuimFerrer/sqlrdd.git por favor con tus avances
gracias por tu ayuda
Fivewinner desde 1.9, programador PHP y Javascript, PWA & HTML5 evangelista
User avatar
Joaquim Ferrer
 
Posts: 102
Joined: Sat Jan 14, 2012 3:46 pm
Location: Barcelona

Re: Incluyendo el SQLRDD

Postby wilsongamboa » Thu Aug 24, 2023 5:56 pm

Joaquim gracias mira esto tengo
c:\demo\sqlrddq>hbmk2 project.hbp
prg\demo01.prg(8) Error F0029 Can't open #include file 'myconn.ch'
hbmk2: Error: Running Harbour compiler (embedded). 1
(c:\hbb\bin\harbour.exe) -n2 prg\demo01.prg -n -q0 -DHBMK_HAS_HBCT=1 -DHBMK_HAS_
HBTIP=1 -DHBMK_HAS_HBFSHIP=1 -DHBMK_HAS_HBXPP=1 -DHBMK_HAS_HBWIN=1 -DHBMK_HAS_XH
B=1 -oC:\Users\gussw\AppData\Local\Temp\hbmk_yolxxb.dir\ -ic:\bcc7\Include -ic:\
bcc7\Include\dinkumware -ic:\bcc7\Include\windows\crtl -ic:\bcc7\Include\windows
\rtl -ic:\bcc7\Include\windows\sdk -ic:\hbb\include -iinclude -ic:\hbb\contrib\x
hb -ic:\hbb\contrib\hbct -ic:\hbb\contrib\hbtip -ic:\hbb\contrib\hbfship -ic:\hb
b\contrib\hbxpp -ic:\hbb\contrib\hbwin -u+c:\hbb\contrib\hbwin\hbwin.ch

saludos
Wilson
creo falta ese archivo myconn.ch
Wilson 'W' Gamboa A
Wilson.josenet@gmail.com
User avatar
wilsongamboa
 
Posts: 548
Joined: Wed Oct 19, 2005 6:41 pm
Location: Quito - Ecuador

Re: Incluyendo el SQLRDD

Postby wilsongamboa » Thu Aug 24, 2023 6:00 pm

mi experiencia
intente cuando apenas salio este producto pero me fallaba cuando hacia use \sistemas\siste001\empre001\ventas\ventas.dbf index \sistemas\siste001\empre001\ventas\ventas.ntx alias ventas
intente con una funcion que ellos tenian para estos casos pero no me funciono
hasta alli llegue eso unido a mis escasos conocimientos de sql en esa epoca ( y ahora ) me detuvieron no me atrevi a comprar la lib por mi falta de conocimiento del campo sql
saludos
wilson
pd: me cai del asiento cuando vi que estaban disponibles los fuentes ja ja ja
gracias a don Marcelo Lombardo y al equipo de xharbour.com !!
Wilson 'W' Gamboa A
Wilson.josenet@gmail.com
User avatar
wilsongamboa
 
Posts: 548
Joined: Wed Oct 19, 2005 6:41 pm
Location: Quito - Ecuador

Re: Incluyendo el SQLRDD

Postby Jimmy » Fri Aug 25, 2023 1:19 am

hi,

under SQL you need a UNIQUE "Identifier" like RECNO() under DBF

Fivewin seems to use "ID" and Xbase++ "__Record" as PRIMARY KEY
SQLRDD use "sr_recno" so everybody can use a other "Identifier"

it is recommend to use "Import" Function which include PRIMARY Key for those SQL Table
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1585
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: Incluyendo el SQLRDD

Postby carlos vargas » Fri Aug 25, 2023 1:33 am

SR_RecnoName()
Returns the name of the column that stores the Recno()

› Syntax


SR_RecnoName( [<cName>] ) ==> cOldSet


› Arguments



<cName> Column name to manage the Recno().




› Return


Returns the status that was current before SR_RecnoName() was called.


› Description


Returns the name of the column that manages the Recno(). By default, the SQLRDD adopts the name SR_RECNO. If you want to use another name, call SR_RecnoName("NAME") before dbUseArea() or dbCreate().
This function is also very useful when we want to open tables not created by SQLRDD, but we can use another auto sequenced numeric column for this purpose.


› Examples


SR_RecnoName( "CAMPO1" )
USE TABELA1 // will use the field COMPO01 as recno(). If this field does not exist, it will generate a runtime error.
Salu2
Carlos Vargas
Desde Managua, Nicaragua (CA)
User avatar
carlos vargas
 
Posts: 1683
Joined: Tue Oct 11, 2005 5:01 pm
Location: Nicaragua

Re: Incluyendo el SQLRDD

Postby carlos vargas » Fri Aug 25, 2023 1:34 am

SR_DeletedName()
Returns the name of the column that manages the Deleted() status

› Syntax


SR_DeletedName( [<cName>] ) ==> cOldSet


› Arguments



<cName> Name column to manage the Deleted() status.




› Return


Returns the status that was current before SR_DeletedName() was called.


› Description


Returns the name of the column that manages the Deleted() status. By default, the SQLRDD adopts the name SR_DELETED. If you want to use another name, call SR_DeletedName("NAME") before dbUseArea() or dbCreate().
This function is also very useful when we want to open tables not created by SQLRDD, but we can use another not null character column for that purpose.
Salu2
Carlos Vargas
Desde Managua, Nicaragua (CA)
User avatar
carlos vargas
 
Posts: 1683
Joined: Tue Oct 11, 2005 5:01 pm
Location: Nicaragua

Re: Incluyendo el SQLRDD

Postby carlos vargas » Fri Aug 25, 2023 1:35 am

se necesita además un campo para controlar el borrado de fila, por defecto es sr_deleted
Salu2
Carlos Vargas
Desde Managua, Nicaragua (CA)
User avatar
carlos vargas
 
Posts: 1683
Joined: Tue Oct 11, 2005 5:01 pm
Location: Nicaragua

Re: Incluyendo el SQLRDD

Postby Joaquim Ferrer » Fri Aug 25, 2023 6:56 am

wilsongamboa wrote:Joaquim gracias mira esto tengo
c:\demo\sqlrddq>hbmk2 project.hbp
prg\demo01.prg(8) Error F0029 Can't open #include file 'myconn.ch'
hbmk2: Error: Running Harbour compiler (embedded). 1
(c:\hbb\bin\harbour.exe) -n2 prg\demo01.prg -n -q0 -DHBMK_HAS_HBCT=1 -DHBMK_HAS_
HBTIP=1 -DHBMK_HAS_HBFSHIP=1 -DHBMK_HAS_HBXPP=1 -DHBMK_HAS_HBWIN=1 -DHBMK_HAS_XH
B=1 -oC:\Users\gussw\AppData\Local\Temp\hbmk_yolxxb.dir\ -ic:\bcc7\Include -ic:\
bcc7\Include\dinkumware -ic:\bcc7\Include\windows\crtl -ic:\bcc7\Include\windows
\rtl -ic:\bcc7\Include\windows\sdk -ic:\hbb\include -iinclude -ic:\hbb\contrib\x
hb -ic:\hbb\contrib\hbct -ic:\hbb\contrib\hbtip -ic:\hbb\contrib\hbfship -ic:\hb
b\contrib\hbxpp -ic:\hbb\contrib\hbwin -u+c:\hbb\contrib\hbwin\hbwin.ch

saludos
Wilson
creo falta ese archivo myconn.ch


Wilson, crea el archivo /include/myconn.ch y le añades
Code: Select all  Expand view

#define __DB__    "mi base de datos"
#define __PWD__   "mi password"
 
Fivewinner desde 1.9, programador PHP y Javascript, PWA & HTML5 evangelista
User avatar
Joaquim Ferrer
 
Posts: 102
Joined: Sat Jan 14, 2012 3:46 pm
Location: Barcelona

PreviousNext

Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 84 guests