|
of_deleterows
|
|
Full name
|
pfc_n_cst_dwsrv_linkage.of_deleterows
|
Access
|
public
|
Extend of
|
integer
|
Return value
|
integer
|
Prototype
|
public function integer of_deleterows(boolean,string[],string[])
|
Name
|
Datatype
|
lb_keyfound
|
boolean
|
li_i
|
Integer
|
li_masterupperbound
|
integer
|
li_rc
|
integer
|
li_upperbound
|
Integer
|
li_x
|
Integer
|
ll_deletecount
|
long
|
ll_row
|
Long
|
ll_toprow
|
Long
|
ls_expression
|
string
|
ls_filter
|
string
|
ls_find
|
String
|
public function integer of_deleterows (boolean ab_delete, string as_masterkeys[], string as_mastervalues[]);//////////////////////////////////////////////////////////////////////////////
//
// Function: of_DeleteRows
//
// Access: public
//
// Arguments:
// ab_delete Switch which determines if Deletes or Discard operations
// will be performed.
// as_masterkeys[] Column Names from the master row that was deleted.
// as_mastervalues[] Column Values from the master row that was deleted.
//
// Returns: Integer
// The number of rows deleted/discarded.
// -1 if an error occurs.
//
// Description:
// Delete the rows that match the master row information.
// These passed in arrays contain all the relevant information about the
// master row that was deleted. The master dw knows which columns
// are key values for all its detail datawindows, but it does not know
// which go with which detail. So it just passes all the information
// and lets the detail datawindow figure out which values it needs.
//
// Note:
// This function is not typically called by the developer.
//
//////////////////////////////////////////////////////////////////////////////
//
// Revision History
//
// Version
// 6.0 Initial version
//
//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1996-1997 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_i
Integer li_x
Integer li_upperbound
integer li_masterupperbound
integer li_rc
long ll_deletecount
String ls_find
Long ll_row
Long ll_toprow
boolean lb_keyfound
string ls_filter
string ls_expression
// Validate the arguments.
li_masterupperbound = UpperBound (as_masterkeys)
if li_masterupperbound <> UpperBound (as_mastervalues) or &
li_masterupperbound = 0 then
return FAILURE
end if
// Not a valid operation for a root datawindow.
If of_IsRoot ( ) Then Return FAILURE
// Create the Find expression to match the rows that need to be deleted.
li_upperbound = UpperBound (inv_linkargs.is_mastercolarg)
For li_i = 1 to li_upperbound
// Get the column data value from the master row that was deleted. This is found
// on the arrays that were passed in.
lb_keyfound = False
for li_x = 1 to li_masterupperbound
If inv_linkargs.is_mastercolarg[li_i] = as_masterkeys[li_x] then
lb_keyfound = True
ls_expression = as_mastervalues[li_x]
Exit
end if
next
if not lb_keyfound Then
// Required data not found.
Return FAILURE
End If
If IsNull(ls_expression) Then ls_expression = ""
If Not Len(Trim(ls_expression))=0 Then
// Construct the Find expression.
If (ls_find <> "") Then ls_find += " And "
If Pos(Lower(ls_expression), 'null') > 0 Then
ls_find += 'IsNull('+ inv_linkargs.is_detailcolarg[li_i]+')'
Else
ls_find += inv_linkargs.is_detailcolarg[li_i] + " = " + ls_expression
End If
End If
Next
// Clear out any filter currently on the dw.
If of_GetStyle() = FILTER Then
ls_filter = idw_requestor.Object.DataWindow.Table.Filter
If ls_filter <> '' And ls_filter <> '?' Then
is_filterexp = ""
idw_requestor.SetFilter("")
idw_requestor.Filter()
End If
End If
// -- Loop around the rows that need to be deleted.
ib_cascadingdelete = True
DO
ll_row = idw_Requestor.Find (ls_find, ll_row, idw_Requestor.RowCount())
if ll_row > 0 then
// Notify that the row is going to be deleted.
li_rc = this.Trigger Event pfc_predeleterow(ll_row)
// Delete or Discard the row.
ib_allowfocuschange = True
If ab_delete Then
li_rc = idw_requestor.DeleteRow(ll_row)
Else
li_rc = idw_requestor.RowsDiscard(ll_row, ll_row, Primary!)
End If
ib_allowfocuschange = False
If li_rc >0 Then ll_deletecount++
// Continue the Delete opearation.
li_rc = of_DeleteDetailRows()
If li_rc >0 Then ll_deletecount += li_rc
end if
LOOP WHILE ll_row > 0
ib_cascadingdelete = False
//If IsValid(gnv_app.inv_debug) then
// gnv_app.inv_debug.of_Message (idw_requestor.ClassName()+'.Linkage.of_DeleteRows'+&
// ' ls_find('+ls_find+')'+' RowCount='+string(idw_requestor.RowCount()) + &
// ' ll_deletecount='+string(ll_deletecount))
//End If
Return ll_deletecount
end function