/*
* Select a WorkArea by the number.
*/
HB_ERRCODE hb_rddSelectWorkAreaNumber( int iArea )
{
PHB_STACKRDD pRddInfo;
HB_TRACE( HB_TR_DEBUG, ( "hb_rddSelectWorkAreaNumber(%d)", iArea ) );
pRddInfo = hb_stackRDD();
if( iArea < 1 || iArea > HB_RDD_MAX_AREA_NUM )
HB_SET_WA( 0 );
else
HB_SET_WA( ( HB_AREANO ) iArea );
return ( pRddInfo->pCurrArea == NULL ) ? HB_FAILURE : HB_SUCCESS;
}
#define HB_SET_WA( n ) \
do \
{ \
pRddInfo->uiCurrArea = n; \
pRddInfo->pCurrArea = ( ( pRddInfo->uiCurrArea < pRddInfo->uiWaNumMax ) ? \
pRddInfo->waList[ pRddInfo->waNums[ pRddInfo->uiCurrArea ] ] : \
NULL ); \
} while( 0 )
#ifndef __XHARBOUR__
#include "fivewin.ch" // as Harbour does not have TRY / CATCH
#define UR_FI_FLAGS 6
#define UR_FI_STEP 7
#define UR_FI_SIZE 5 // by Lucas for Harbour
#endif
CASE uInfoType == DBI_FULLPATH // 10 /* The Full path to the data file */
MSGINFO("IN SQL FULL PATH DOES NOT MATTER!", "DBI_FULLPATH ")
uReturn := ""
#define UR_FI_SIZE 5 // by Lucas for Harbour
static PHB_ITEM hb_usrRelInfoToItem( LPDBRELINFO pRelInfo )
{
PHB_ITEM pItem;
pItem = hb_itemArrayNew( UR_RI_SIZE );
if( pRelInfo->itmCobExpr )
hb_itemCopy( hb_arrayGetItemPtr( pItem, UR_RI_BEXPR ), pRelInfo->itmCobExpr );
if( pRelInfo->abKey )
hb_itemCopy( hb_arrayGetItemPtr( pItem, UR_RI_CEXPR ), pRelInfo->abKey );
hb_itemPutL( hb_arrayGetItemPtr( pItem, UR_RI_SCOPED ), pRelInfo->isScoped );
hb_itemPutL( hb_arrayGetItemPtr( pItem, UR_RI_OPTIMIZED ), pRelInfo->isOptimized );
hb_itemPutNI( hb_arrayGetItemPtr( pItem, UR_RI_PARENT ), pRelInfo->lpaParent ? pRelInfo->lpaParent->uiArea : 0 );
hb_itemPutNI( hb_arrayGetItemPtr( pItem, UR_RI_CHILD ), pRelInfo->lpaChild ? pRelInfo->lpaChild->uiArea : 0 );
hb_itemPutPtr( hb_arrayGetItemPtr( pItem, UR_RI_NEXT ), pRelInfo->lpdbriNext );
return pItem;
}
/*
* DBRELINFO
* ---------
* The Relationship Info structure
*/
typedef struct _DBRELINFO
{
PHB_ITEM itmCobExpr; /* Block representation of the relational SEEK key */
PHB_ITEM abKey; /* String representation of the relational SEEK key */
HB_BOOL isScoped; /* Is this relation scoped */
HB_BOOL isOptimized; /* Is relation optimized */
struct _AREA * lpaParent; /* The parent of this relation */
struct _AREA * lpaChild; /* The parents children */
struct _DBRELINFO * lpdbriNext; /* Next child or parent */
} DBRELINFO;
typedef DBRELINFO * LPDBRELINFO;
2) What shall we put in ADO_INFO :
DBI_FULLPATH
DBI_TABLEEXT
DBI_FILEHANDLE
struct _DBRELINFO * lpdbriNext; /* Next child or parent */
lucasdebeltran wrote:
Pure Browse() works, but scrolling does not work ok.
Append blank fails.
STATIC FUNCTION ADO_APPEND( nWA, lUnLockAll )
LOCAL oRecordSet := USRRDD_AREADATA( nWA )[ WA_RECORDSET ]
LOCAL aWdata := USRRDD_AREADATA( nWA )
HB_SYMBOL_UNUSED( lUnLockAll )
oRecordSet:AddNew()
oRecordSet:Update()
IF !lUnlockAll
ADO_UNLOCK(nWA)
ENDIF
AADD(aWdata[ WA_LOCKLIST ],oRecordSet:BookMark)
RETURN HB_SUCCESS
HB_FUNC( DBSETRELATION )
{
AREAP pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer();
if( pArea )
{
DBRELINFO dbRelations;
AREAP pChildArea;
HB_AREANO uiChildArea;
char * szAlias = NULL;
if( hb_pcount() < 2 ||
hb_param( 1, HB_IT_NUMERIC | HB_IT_STRING ) == NULL ||
! ( HB_ISNIL( 4 ) || HB_ISLOG( 4 ) ) )
{
hb_errRT_DBCMD( EG_ARG, EDBCMD_REL_BADPARAMETER, NULL, HB_ERR_FUNCNAME );
return;
}
if( HB_ISNUM( 1 ) )
{
uiChildArea = ( HB_AREANO ) hb_parni( 1 );
}
else
{
int iArea = hb_rddGetCurrentWorkAreaNumber();
hb_rddSelectWorkAreaAlias( hb_parcx( 1 ) );
if( hb_vmRequestQuery() )
return;
uiChildArea = ( HB_AREANO ) hb_rddGetCurrentWorkAreaNumber();
hb_rddSelectWorkAreaNumber( iArea );
}
pChildArea = uiChildArea ? ( AREAP ) hb_rddGetWorkAreaPointer( uiChildArea ) : NULL;
if( ! pChildArea )
{
hb_errRT_BASE( EG_NOALIAS, EDBCMD_NOALIAS, NULL, szAlias, 0 );
return;
}
dbRelations.itmCobExpr = hb_itemNew( hb_param( 2, HB_IT_BLOCK ) );
dbRelations.abKey = hb_itemNew( hb_param( 3, HB_IT_STRING ) );
dbRelations.isScoped = hb_parl( 4 );
dbRelations.isOptimized = HB_FALSE;
dbRelations.lpaChild = pChildArea;
dbRelations.lpaParent = pArea;
dbRelations.lpdbriNext = NULL;
SELF_SETREL( pArea, &dbRelations );
}
else
hb_errRT_DBCMD( EG_NOTABLE, EDBCMD_NOTABLE, NULL, HB_ERR_FUNCNAME );
}
static void hb_sxRollBackChild( AREAP pArea, PHB_ITEM pItem )
{
LPDBRELINFO lpdbRelation = pArea->lpdbRelations;
while( lpdbRelation )
{
if( SELF_INFO( lpdbRelation->lpaChild, DBI_ROLLBACK, pItem ) != HB_SUCCESS )
break;
hb_sxRollBackChild( lpdbRelation->lpaChild, pItem );
lpdbRelation = lpdbRelation->lpdbriNext;
}
}
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 42 guests