of_register


pfcdwsrv.pbl   >   pfc_n_cst_dssrv_multitable   >   of_register   

Full name pfc_n_cst_dssrv_multitable.of_register
Access public
Extend of integer
Return value integer
Prototype public function integer of_register(string,string[],string[],boolean,integer)

Name Datatype
No Data

Name Datatype
li_cnt integer
li_columncnt integer
li_keycolumncnt integer
li_openslot integer
li_tablecount integer
li_updatecolumncnt integer
ls_allcolumns string
ls_column string
ls_findexp string
SEPARATOR string

public function integer of_register (string as_table, string as_keycolumns[], string as_updateablecolumns[], boolean ab_keyinplace, integer ai_whereoption);//////////////////////////////////////////////////////////////////////////////
//
//	Function:  		of_Register
//
//	Access:    		Public
//
//	Arguments: 
//   as_table: 			A string containing the table to update
//   as_keycolumns[]:	A string array containing the key columns to be used for update
//	  as_updateablecolumns[]: A string array containing a list of updateable columns
//	  ab_keyinplace:		A boolean when TRUE specifies use Update Key in Place, otherwise
//						  		use delete, then insert on key changes
//   ai_whereoption: 	An integer that corresponds to the datawindow Update Where
//						 		option
//
//	Returns: 		Integer
// 1 if it succeeds
//	-1 if an error occurs. 
//
//	Description:  	
//	Registers a table and its corresponding update characteristics with the 
//	service.
//
//////////////////////////////////////////////////////////////////////////////
//
//	Revision History
//
//	Version
//	6.0   Initial version - Replaces obsoleted function of_AddToUpdate(...)
//	6.0	Enhanced to perform more validation.
// 6.0	Enhanced to find openslot.
//
//////////////////////////////////////////////////////////////////////////////
//
//	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.
//
//////////////////////////////////////////////////////////////////////////////

constant	string SEPARATOR = '@#$'
integer	li_tablecount
integer	li_cnt
integer	li_openslot
integer	li_columncnt
integer	li_keycolumncnt
integer	li_updatecolumncnt
string	ls_column
string	ls_allcolumns
string	ls_findexp

//  Validate the passed arguments
IF IsNull (as_table) OR Len(Trim(as_table)) = 0 THEN Return -1
IF UpperBound(as_keycolumns)=0 Then Return -1
IF IsNull (ab_keyinplace) THEN Return -1 
IF IsNull (ai_whereoption) OR (ai_whereoption < 0) OR (ai_whereoption > 2) THEN Return -1

// Create string containing every column in the datawindow.
li_columncnt = Integer ( ids_requestor.Describe ( "DataWindow.Column.Count" ) ) 
For li_cnt = 1 to li_columncnt
	ls_column = ids_requestor.Describe ( "#" + String(li_cnt) + ".Name" )
	IF ls_column = '!' Then Return -1

	ls_allcolumns += ' ' + SEPARATOR + Lower(Trim(ls_column)) + SEPARATOR + ' '
Next

// Make sure every passed in key column is found.
li_keycolumncnt = UpperBound(as_keycolumns)
For li_cnt = 1 To li_keycolumncnt
	as_keycolumns[li_cnt] = Lower(Trim(as_keycolumns[li_cnt]))
	ls_findexp = SEPARATOR+as_keycolumns[li_cnt]+SEPARATOR
	If Pos(ls_allcolumns, ls_findexp) = 0 Then
		// Column was not found.
		Return -1
	End If
Next

// Make sure every passed in update column is found.
li_updatecolumncnt = UpperBound(as_updateablecolumns[])
For li_cnt = 1 To li_updatecolumncnt
	as_updateablecolumns[li_cnt] = Lower(Trim(as_updateablecolumns[li_cnt]))
	ls_findexp = SEPARATOR+as_updateablecolumns[li_cnt]+SEPARATOR
	If Pos(ls_allcolumns, ls_findexp) = 0 Then
		// Column was not found.
		Return -1
	End If
Next

// Get the Index for the new entry (openslot)
li_tablecount = UpperBound ( inv_newupdate ) 
For li_cnt = 1 to li_tablecount
	If Trim(inv_newupdate[li_cnt].s_updatetable) = '' Then
		li_openslot = li_cnt
		Exit
	End If
Next
If li_openslot = 0 Then
	li_openslot = li_tablecount + 1
End If

// Add this table to the attribute class of update tables 
inv_newupdate[li_openslot].s_updatetable = Trim(as_table)
inv_newupdate[li_openslot].i_whereoption = ai_whereoption
inv_newupdate[li_openslot].b_keyupdateinplace = ab_keyinplace
inv_newupdate[li_openslot].s_updatecolumns = as_updateablecolumns
inv_newupdate[li_openslot].s_keycolumns = as_keycolumns

Return 1

end function

     
Name Owner
pfc_n_cst_dssrv_multitable.of_register pfc_n_cst_dssrv_multitable
pfc_n_cst_dssrv_multitable.of_register pfc_n_cst_dssrv_multitable

     
Name Owner
datastore.describe datastore
systemfunctions.integer systemfunctions
systemfunctions.isnull systemfunctions
systemfunctions.len systemfunctions
systemfunctions.lower systemfunctions
systemfunctions.pos systemfunctions
systemfunctions.string systemfunctions
systemfunctions.trim systemfunctions
systemfunctions.upperbound systemfunctions

     
Full name
No Data

     
Name Scope
No Data