of_DistinctValues


pfcmain.pbl   >   pfc_n_tr   >   of_DistinctValues   

Full name pfc_n_tr.of_DistinctValues
Access public
Extend of long
Return value long
Prototype public function long of_DistinctValues(string,string,ref string[])

Name Datatype
No Data

Name Datatype
ll_rc long
ls_name string
ls_sqlstatement string
ls_value string

public function long of_DistinctValues (string as_table, string as_column, ref string as_values[]);//////////////////////////////////////////////////////////////////////////////
//	Public Function:  of_DistinctValues
//	Arguments:		as_table:  	a SQL table name
//						as_column:  a database column name in passed SQL table
//						as_values:  string array, passed by reference to hold the returned values
//	Returns:			long - the SQLCode based on the SQL fetch
//	Description:	Get the distinct values from the database
//////////////////////////////////////////////////////////////////////////////
//	Rev. History	Version
//						5.0   Initial version
//////////////////////////////////////////////////////////////////////////////
//	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.
//////////////////////////////////////////////////////////////////////////////
long	ll_rc
string	ls_sqlstatement
string	ls_value
string	ls_name

// Build the SQL Select statement
ls_sqlstatement = "SELECT DISTINCT " + as_column + " FROM " + as_table

// If SQLSpy service is on, add to the history
if IsValid (gnv_app) then
	if IsValid(gnv_app.inv_debug) then
		if IsValid (gnv_app.inv_debug.inv_sqlspy) then
			ls_name = this.is_Name
			if Len (ls_name) = 0 then
				ls_name = this.ClassName()
			end if
			gnv_app.inv_debug.inv_sqlspy.of_SQLSyntax &
				("Dynamic SQL using " + ls_name, ls_sqlstatement)
		end if 
	end if
end if

// Execute the SQL
prepare sqlsa from :ls_sqlstatement using this;
describe sqlsa into sqlda;
declare c_values_cursor	dynamic cursor for sqlsa;
open dynamic c_values_cursor using descriptor sqlda;
fetch c_values_cursor using descriptor sqlda;
ll_rc = this.SQLCode

// Retrieve the distinct values and add them to the array
do while this.SQLCode = 0 
	choose case sqlda.OutParmType[1]
		case TypeString!
			ls_value = GetDynamicString (sqlda, 1)
		case TypeDate!
			ls_value = String (GetDynamicDate (sqlda, 1))
		case TypeTime!
			ls_value = String (GetDynamicTime (sqlda, 1))
		case TypeDateTime!
			ls_value = String (GetDynamicDateTime (sqlda, 1))
		case else
			ls_value = String (GetDynamicNumber (sqlda, 1))
	end choose

	as_values[UpperBound(as_values)+1] =  ls_value
	fetch c_values_cursor using descriptor sqlda;
	ll_rc = this.SQLCode
loop

close c_values_cursor;

return ll_rc
end function

     
Name Owner
pfc_w_filtersimple.of_getvalues pfc_w_filtersimple

     
Name Owner
powerobject.classname powerobject
systemfunctions.isvalid systemfunctions
systemfunctions.len systemfunctions
systemfunctions.string systemfunctions
systemfunctions.upperbound systemfunctions
systemfunctions.GetDynamicString systemfunctions
systemfunctions.GetDynamicDate systemfunctions
systemfunctions.GetDynamicTime systemfunctions
systemfunctions.GetDynamicDateTime systemfunctions
systemfunctions.GetDynamicNumber systemfunctions
pfc_n_cst_sqlspy.of_sqlsyntax pfc_n_cst_sqlspy

     
Full name
demopfc

     
Name Scope
No Data