of_buildexpression


pfcdwsrv.pbl   >   pfc_n_cst_dwsrv   >   of_buildexpression   

Full name pfc_n_cst_dwsrv.of_buildexpression
Access public
Extend of any
Return value any
Prototype public function any of_buildexpression(long,string,string,string)

Name Datatype
No Data

Name Datatype
ls_coltype string
ls_expression string
ls_value string

public function any of_buildexpression (long al_row, string as_column, string as_operator, string as_optionalvalue);//////////////////////////////////////////////////////////////////////////////
//
//	Function:  of_BuildExpression
//
//	Access:    Public
//
//	Arguments:
//   al_row			   : The row reference
//   as_column    	: The column name reference
//	  as_operator		: The desired operator.
//								"="	Equals	
//								">"	Greater than	
//								"<"	Less than	
//								"<>"	Not equal	
//								">="	Greater than or equal	
//								"<="	Less than or equal	
//	  as_optionalvalue: An optional value.  If found it will not used the
//							  row/column value.
//
//	Returns:  Any
//	  The column value cast to an any datatype
//
//	Description:  
//	Returns a complete expression string that can be used on any Find or 
//	Filter operation.  
//	For example, 'hired_date > Date("1/1/95")' will be the result for 
//	as_column='hired_date', as_operator='>', as_optionalvalue='1/1/95'.
//
//////////////////////////////////////////////////////////////////////////////
//
//	Revision History
//
//	Version
//	6.0   Initial version
// 7.0	Added "char" datatype to case statement
//
//////////////////////////////////////////////////////////////////////////////
//
//	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.
//
//////////////////////////////////////////////////////////////////////////////

string	ls_expression
string	ls_coltype
string	ls_value

// Verify passed arguments.
If IsNull(idw_requestor) Or Not IsValid(idw_requestor) Then Return '!'
If as_optionalvalue = '#@notapplicable@#' Then
	// Only test row number when there is no optional value.
	If IsNull(al_row) or al_row <= 0 or al_row > idw_requestor.RowCount() Then Return '!'
End If
If Len(Trim(as_column))=0 or IsNull(as_column) Then Return '!'
If as_operator='=' or as_operator='>' or as_operator='<' or as_operator='<>' or &
	as_operator='>=' or as_operator='<=' Then
	// Good value.
Else
	Return '!'
End If

// Get the column type.
ls_coltype = idw_requestor.Describe(as_column+'.ColType')
If ls_coltype='!' or ls_coltype='?' Then Return '!'

// Either get the current value or use the passed in value.
If as_optionalvalue = '#@notapplicable@#' Then
	ls_value = string( of_GetItemAny(al_row, as_column) )
Else
	ls_value = as_optionalvalue
End If

If IsNull(ls_value) Then
	//-- Build NULL value expressions. --
	If as_operator='=' Then
		ls_expression = 'IsNull('+as_column+')'
	ElseIf as_operator='<>' Then
		ls_expression = 'Not IsNull('+as_column+')'		
	Else
		ls_expression = '!'
	End If
Else
	//-- Build NonNull value expressions. --

	// Start building the Find/Filter expression.
	ls_expression = as_column + ' ' + as_operator + ' '

	// Wrap the value with datatype conversion functions, so that
	// the value is valid in Filter and Find expressions.
	//	Note: a number value does not need any special handling.
	Choose Case Lower ( Left (ls_coltype, 5 ) )
		
		// CHARACTER DATATYPE		
		Case "char(", "char"	
			ls_expression += "'" + ls_value + "'"
	
		// DATE DATATYPE	
		Case "date"					
			ls_expression += "Date('" + ls_value  + "')" 

		// DATETIME DATATYPE
		Case "datet"				
			ls_expression += "DateTime('" + ls_value + "')" 

		// TIME DATATYPE
		Case "time", "times"		
			ls_expression += "Time('" + ls_value + "')" 
	
		// Number
		Case 	Else
			ls_expression += ls_value

	End Choose
End If

Return ls_expression
end function

     
Name Owner
pfc_n_cst_dwsrv_linkage.of_scrolldetails pfc_n_cst_dwsrv_linkage
pfc_n_cst_dwsrv_linkage.of_filterdetails pfc_n_cst_dwsrv_linkage
pfc_n_cst_dwsrv_linkage.of_keysync pfc_n_cst_dwsrv_linkage
pfc_n_cst_dwsrv.of_buildexpression pfc_n_cst_dwsrv
pfc_n_cst_dwsrv.of_buildexpression pfc_n_cst_dwsrv

     
Name Owner
datawindow.describe datawindow
datawindow.rowcount datawindow
systemfunctions.isnull systemfunctions
systemfunctions.isvalid systemfunctions
systemfunctions.left systemfunctions
systemfunctions.len systemfunctions
systemfunctions.lower systemfunctions
systemfunctions.string systemfunctions
systemfunctions.trim systemfunctions
pfc_n_cst_dwsrv.of_GetItemany pfc_n_cst_dwsrv

     
Full name
No Data

     
Name Scope
No Data