of_retrieve


pfcapsrv.pbl   >   pfc_n_cst_tvsrv_levelsource   >   of_retrieve   

Full name pfc_n_cst_tvsrv_levelsource.of_retrieve
Access public
Extend of long
Return value long
Prototype public function long of_retrieve(integer,any[20],ref n_ds)

Name Datatype
No Data

Name Datatype
li_Cnt Integer
li_Index Integer
li_numcols Integer
ll_NewRows Long
ll_Rows Long
ls_cacheid String
ls_column string[]
ls_expression String
ls_filter String
ls_operators string[]
lw_parentwindow window

public function long of_retrieve (integer ai_level, any aa_arg[20], ref n_ds ads_data);//////////////////////////////////////////////////////////////////////////////
//	Public Function:	of_Retrieve
//	Arguments:		ai_Level		The TreeView level to be retrieved.
//						aa_Arg[20]	An array of type Any that will contain the retrieval
//									argument values.  
//						ads_obj		The datastore holding the retrieved data.  Passed by reference
//	Returns:			Integer
//						Returns 1 if the data source was added successfully, 
//						-1 if an error occurrs.
//						-2 Key columns were not defined for the level
//						-3 Retrieve from datastore was not successful
//						-4 if datawindow object is not valid
//	Description:	Retrieve the data for a treeview level.
//////////////////////////////////////////////////////////////////////////////
//	Rev. History	Version
//						6.0   Initial version
//						7.0   Fix call to of_BuildExpression, requires string argument
//////////////////////////////////////////////////////////////////////////////
//	Copyright © 1996-1999 Sybase, Inc. and its subsidiaries.  All rights reserved.  Any distribution of the 
// PowerBuilder Foundation Classes (PFC) source code by other than Sybase, Inc. and its subsidiaries is prohibited.
//////////////////////////////////////////////////////////////////////////////
Integer		li_Cnt, li_Index, li_numcols
Long			ll_NewRows, ll_Rows
String		ls_cacheid, ls_filter, ls_expression
string		ls_column[], ls_operators[]
window		lw_parentwindow

//	Check arguments
If IsNull(itv_requestor) or not isvalid(itv_requestor) Then Return -1
If IsNull(ai_level) or (ai_level < 1) Then Return -1

// Determine if the level is recursive
If ai_Level > UpperBound(inv_attrib) Then
	li_Index = UpperBound(inv_attrib)
Else
	li_Index = ai_Level
End If

// check datawindow object for existence.  This is set to ""
// in of_register() when the datawindow is not updateable
if inv_attrib[li_Index].is_DataObject= "" then return -4

// Set up the cache id 
ls_cacheid = CACHE_ID + string(li_index)

// Retrieve data into the DataStore
// pass the arguments to the cache
If (inv_attrib[li_Index].is_method = inv_cache.SQL) or &
	(inv_attrib[li_Index].is_method = inv_cache.RETRIEVE) Then
		// register the arguments; retrieve the cache and get the reference
		inv_cache.of_RegisterArgs(ls_cacheid, aa_Arg)
		If inv_cache.of_Refresh(ls_cacheid) < 0 Then return -1
End If

// Get a reference to the cache - data was retrieved on registration
IF inv_cache.of_GetRegistered(ls_cacheid, ads_data) <> 1 then Return -1

// turn back on the base service as cache does not turn it on
ads_data.of_SetBase(TRUE)

//// datastore needs parent window reference to perform updates
//itv_requestor.of_Getparentwindow(lw_parentwindow)
//ads_data.of_SetParentWindow(lw_parentwindow)

// filter the datastore to return only the necessary rows
If (inv_attrib[li_Index].is_method = inv_cache.SQL) or &
	(inv_attrib[li_Index].is_method = inv_cache.RETRIEVE) Then
		// do not filter.  The refresh should have done the work for those methods
Else
	of_parsecols(inv_attrib[li_index].is_filtercols, ls_operators, ls_column)
	for li_cnt = 1 to upperbound(ls_column)
		
		ls_expression = ads_data.inv_base.of_buildexpression(0, ls_column[li_cnt], "=", String (aa_Arg[li_cnt]))
		If Pos(ls_operators[li_cnt], "N") > 0 Then
			ls_expression = " NOT (" + ls_expression + ") "
		End If
		If Pos(ls_operators[li_cnt], "A") > 0 Then
			ls_expression = " AND " + ls_expression
		End If
		If Pos(ls_operators[li_cnt], "O") > 0 Then
			ls_expression = " OR " + ls_expression
		End If
		ls_filter = ls_filter + ls_expression
	end for
	ads_data.setfilter(ls_filter)
	ads_data.filter()
End If

ll_NewRows = ads_data.RowCount()

//// Append the rows to the level's DataStore
//ll_Rows = inv_attrib[li_Index].ids_obj.RowCount()
//ids_Buffer.RowsCopy(1, ll_NewRows, Primary!, inv_attrib[li_Index].ids_obj, (ll_Rows + 1), Primary!)
//
//// Clear the status flags for the new rows
//For li_Cnt = (ll_Rows + 1) To (ll_Rows + ll_NewRows)
//	inv_attrib[li_Index].ids_obj.SetItemStatus(li_Cnt, 0, Primary!, DataModified!)
//	inv_attrib[li_Index].ids_obj.SetItemStatus(li_Cnt, 0, Primary!, NotModified!)
//Next

Return ll_NewRows

end function

     
Name Owner
pfc_u_tvs.of_retrieve pfc_u_tvs

     
Name Owner
datastore.filter datastore
datastore.rowcount datastore
datastore.setfilter datastore
systemfunctions.isnull systemfunctions
systemfunctions.isvalid systemfunctions
systemfunctions.pos systemfunctions
systemfunctions.string systemfunctions
systemfunctions.upperbound systemfunctions
pfc_n_cst_tvsrv_levelsource.of_parsecols pfc_n_cst_tvsrv_levelsource
pfc_n_cst_dwcache.of_getregistered pfc_n_cst_dwcache
pfc_n_cst_dwcache.of_registerargs pfc_n_cst_dwcache
pfc_n_cst_dwcache.of_refresh pfc_n_cst_dwcache
pfc_n_cst_dssrv.of_buildexpression pfc_n_cst_dssrv
pfc_n_ds.of_setbase pfc_n_ds

     
Full name
No Data

     
Name Scope
No Data