Estimado Alexandre,
No, no es posible convertir directamente un objeto FWMariaRowSet (o FWRowSet) en un alias de xBase tradicional. 0-cite-0
Respuesta
Los objetos FWMariaRowSet y FWRowSet son clases que emulan el comportamiento de un alias de xBase, pero no son áreas de trabajo reales de la RDD (Replaceable Database Driver). 0-cite-1 Estos objetos mantienen los datos en memoria en el array aData y proporcionan métodos como Skip(), GoTo(), FieldGet(), etc., que imitan la interfaz de navegación de DBF. 0-cite-2
No existe una función SetAlias() en FiveWin que convierta un RowSet en un alias tradicional.<cite /> La arquitectura del framework está diseñada para que trabajes directamente con el objeto RowSet, no con alias.<cite />
Alternativas
1. Usar el objeto directamente con xBrowse():
Tu código actual ya es la forma correcta:
cCmdSql := "SELECT * FROM cadastro"
oRowSet := oConexao:RowSet( cCmdSql )
xBrowse( oRowSet )
TXBrowse está diseñado para trabajar directamente con objetos RowSet. 0-cite-3
2. Acceder a los datos del RowSet:
Puedes navegar y acceder a los datos usando los métodos del objeto:
oRowSet:GoTop()
DO WHILE !oRowSet:Eof()
? oRowSet:FieldGet("campo")
oRowSet:Skip()
ENDDO
3. Si necesitas un alias DBF real:
Si realmente necesitas trabajar con un alias tradicional, tendrÃas que exportar los datos del RowSet a un archivo DBF temporal y luego abrirlo con USE.<cite /> Sin embargo, esto eliminarÃa las ventajas de trabajar directamente con la base de datos SQL.
Notes
La clase FWMariaRowSet hereda de FWRowSet y proporciona funcionalidad adicional especÃfica para MariaDB/MySQL. 0-cite-4 Ambas clases implementan una interfaz compatible con la navegación de xBase pero no son áreas de trabajo RDD reales, por lo que no pueden usarse con la sintaxis de alias tradicional como tmp->campo.<cite />
Wiki pages you might want to explore:
Citations
File: source/internal/fwrowset.prg (L18-28)
CLASS FWRowSet
PROTECTED:
DATA xBlankRow
DATA fld_list
DATA aNatural
EXPORT:
DATA aData INIT Array( 0 )
DATA cFile INIT 'ARRAY'
DATA cAlias INIT 'ARRAY'
File: source/internal/fwrowset.prg (L50-88)
METHOD RecCount() INLINE Len( ::aData )
METHOD LastRec() INLINE Len( ::aData )
METHOD RecordCount() INLINE Len( ::aData )
METHOD RecNo() INLINE ::BookMark //::nAt
METHOD FCount() INLINE Len( ::aStruct )
METHOD FieldPos( cFld )
METHOD FieldName( n ) INLINE ( n := ::FieldPos( n ), ;
If( n > 0 .and. n <= Len( ::aStruct ), ;
::aStruct[ n ][ 1 ], '' ) )
METHOD FieldType( n ) INLINE ( n := ::FieldPos( n ), ;
If( n > 0 .and. n <= Len( ::aStruct ), ;
::aStruct[ n ][ 2 ], '' ) )
METHOD FieldLen( n ) INLINE ( n := ::FieldPos( n ), ;
If( n > 0 .and. n <= Len( ::aStruct ), ;
::aStruct[ n ][ 3 ], 0 ) )
METHOD FieldDec( n ) INLINE ( n := ::FieldPos( n ), ;
If( n > 0 .and. n <= Len( ::aStruct ), ;
::aStruct[ n ][ 4 ], 0 ) )
METHOD Bof() INLINE ( ::nAt < 1 .or. Empty( ::aData ) )
METHOD Eof() INLINE ::nAt > ::KeyCount()
METHOD CellValue( nRow, nCol )
METHOD CellGet( aRow, nFld ) PROTECTED
METHOD CellPut( aRow, nFld, uValue ) PROTECTED
METHOD FieldGet( n ) INLINE ::CellGet( nil, n )
METHOD FieldPut( nFld, uValue )
METHOD GoTo( n ) INLINE ( ::BookMark := n )
METHOD GoTop() INLINE ::nAt := Min( 1, ::KeyCount() )
METHOD GoBottom() INLINE ::nAt := Max( 1, ::KeyCount() )
METHOD Skip( n ) INLINE ::KeyGoTo( ::nAt + If( n == nil, 1, n ) )
METHOD Skipper( nToSkip )
METHOD BookMark( uBm ) SETGET
METHOD KeyNo() INLINE ::nAt
METHOD KeyGoTo( nkeyNo ) INLINE ::nAt := Max( 1, Min( nKeyNo, ::KeyCount() ) )
METHOD KeyCount() INLINE Eval( ::bKeyCount )
File: source/internal/fwmaria.prg (L1299-1310)
CLASS FWMariaRowSet FROM FWRowSet STATIC
DATA hLastRec INIT 0 PROTECTED
DATA oCn //READONLY
DATA oReplServer // replication
DATA bOnReplFail
DATA hBof AS LOGICAL INIT .f. PROTECTED
DATA hAt PROTECTED
ACCESS nAt INLINE ::hAt
ASSIGN nAt( x ) INLINE If( ::hAt == x, nil, ( ::CheckSave(), ::hAt := x ) )
File: samples/ui/xbrowse/testxbr3.prg (L435-436)
@ 0,0 XBROWSE oBrw OF ownd RECSET oRs AUTOCOLS AUTOSORT FOOTERS FASTEDIT ;
LINES CELL