|
of_update
|
|
Full name
|
pfc_n_cst_dssrv_multitable.of_update
|
Access
|
public
|
Extend of
|
integer
|
Return value
|
integer
|
Prototype
|
public function integer of_update(boolean,boolean)
|
Name
|
Datatype
|
lb_is_key
|
boolean
|
lb_is_updateable
|
boolean
|
li_i
|
integer
|
li_keycolidx
|
integer
|
li_num_cols
|
integer
|
li_num_keys
|
integer
|
li_num_tables
|
integer
|
li_num_updateable
|
integer
|
li_rc
|
integer
|
li_tabidx
|
integer
|
li_updcolidx
|
integer
|
lnv_originalupdate
|
n_cst_dssrv_multitableattrib
|
ls_column
|
string
|
ls_mod_string
|
string
|
public function integer of_update (boolean ab_accepttext, boolean ab_resetflags);//////////////////////////////////////////////////////////////////////////////
//
// Function: of_Update (Format 3)
//
// Access: Public
//
// Arguments:
// ab_accepttext: A boolean value specifying whether the DataWindow control
// should automatically perform an AcceptText prior to
// performing the update:
// TRUE -- Perform AcceptText
// FALSE -- Do not perform AcceptText
// ab_resetflags: A boolean value specifying whether datawindow should
// automatically reset the update flags:
// TRUE -- Reset the flags
// FALSE -- Do not reset the flags
//
// Returns: Integer
// 1 if it succeeds
// -1 if an update error occurs.
// -2 if the Modify for Update Characteristics failed
//
// Description: Update the datawindow for all the registered tables.
//
//////////////////////////////////////////////////////////////////////////////
//
// Revision History
//
// Version
// 5.0 Initial version
// 7.0 Local variable datatype changed from os_updcharacteristics to n_cst_dssrv_multitableattrib type
// 7.0 Local variable name changed from lstr_originalupdate to lnv_originalupdate
//////////////////////////////////////////////////////////////////////////////
//
// 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_num_tables
integer li_num_cols
integer li_tabidx
integer li_updcolidx
integer li_keycolidx
integer li_i
integer li_rc
integer li_num_updateable
integer li_num_keys
boolean lb_is_updateable
boolean lb_is_key
string ls_column
string ls_mod_string
n_cst_dssrv_multitableattrib lnv_originalupdate
// Verify passed arguments.
IF IsNull (ab_accepttext) THEN Return -1
IF IsNull (ab_resetflags) THEN Return -1
// Get the number of tables involved.
li_num_tables = UpperBound (inv_newupdate)
IF li_num_tables = 0 THEN Return -2
// First save the original update characteristics for later restoration.
li_rc = of_StoreUpdateSettings ( lnv_originalupdate )
If li_rc < 0 Then Return li_rc
// Get the number of columns on the datawindow.
li_num_cols = Integer (ids_requestor.Describe ( "DataWindow.Column.Count" ))
// Loop thru each table that is registered, modify the characteristics and update.
FOR li_tabidx = 1 to li_num_tables
// (start new string) Set the Update Table.
ls_mod_string = "DataWindow.Table.UpdateTable='" + &
inv_newupdate[li_tabidx].s_updatetable +"' "
// Set the Update Where Option.
ls_mod_string += "DataWindow.Table.UpdateWhere=" + &
String(inv_newupdate[li_tabidx].i_whereoption) +" "
// Set the Update Key in Place flag.
If inv_newupdate[li_tabidx].b_keyupdateinplace THEN
ls_mod_string += "DataWindow.Table.UpdateKeyInPlace=yes "
Else
ls_mod_string += "DataWindow.Table.UpdateKeyInPlace=no "
End If
// Get the number of UpdateColumns and Keys.
li_num_updateable = UpperBound ( inv_newupdate[li_tabidx].s_updatecolumns )
li_num_keys = UpperBound ( inv_newupdate[li_tabidx].s_keycolumns )
// Loop around all columns.
FOR li_updcolidx = 1 to li_num_cols
ls_column = ids_requestor.Describe ( "#" + String(li_updcolidx) + ".Name" )
//Determine if this column should be Updatable.
lb_is_updateable = FALSE
FOR li_i = 1 to li_num_updateable
IF Lower(ls_column) = Lower(inv_newupdate[li_tabidx].s_updatecolumns[li_i]) THEN
lb_is_updateable = TRUE
EXIT
END IF
NEXT
// Set the Updatable flag as appropriate.
IF lb_is_updateable THEN
ls_mod_string += ls_column + ".Update=Yes "
ELSE
ls_mod_string += ls_column + ".Update=No "
END IF
// Determine if this column should be a Key.
lb_is_key = FALSE
FOR li_keycolidx = 1 to li_num_keys
IF Lower(ls_column) = Lower(inv_newupdate[li_tabidx].s_keycolumns[li_keycolidx]) THEN
lb_is_key = TRUE
EXIT
END IF
NEXT
// Set the Key flag as appropriate.
IF lb_is_key THEN
ls_mod_string += ls_column + ".Key=Yes "
ELSE
ls_mod_string += ls_column + ".Key=No "
END IF
NEXT
// Modify the datawindow object.
IF ids_requestor.Modify ( ls_mod_string ) <> "" THEN Return -2
// Update the DataWindow, Make sure the Flags are Not Reset.
li_rc = ids_requestor.Update ( ab_accepttext, FALSE )
IF li_rc <> 1 THEN Return li_rc
NEXT
// Restore the update characteristics to their original settings.
li_rc = of_RestoreUpdateSettings ( lnv_originalupdate )
If li_rc < 0 Then Return li_rc
// All updates have succesfully occurred, Reset the flags if appropriate.
IF ab_resetflags = TRUE THEN ids_requestor.ResetUpdate ( )
Return 1
end function