Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Default Values for Table fields
Message
From
15/05/2005 12:16:18
Vinod Parwani
United Creations L.L.C.
Ad-Dulayl, Jordan
 
 
To
15/05/2005 09:22:36
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01014331
Message ID:
01014354
Views:
19
>>>>Local views are not taking default values from table fields, is there anything I'm missing to get these values from tables.
>>>
>>>View fields, like table fields have default values
>>>
>>>When you define a table you either use the default as in
>>>
>>>create table pp ;
>>>  (  field1   c(2) default '**' ;
>>>  )
>>>
>>>
>>>or you set them
>>>
>>>=dbsetprop('pp.Field1', 'Field', 'DefaultValue', '**')
>>>
>>>
>>>So you can set them with dbsetprop() for the view
>>>
>>>An alternative is to create a little program that copies the default values, format, caption, inputmask of the base tables to the view fields
>>
>>Is there any generic routine available to copy these values from table to view.
>
>
>None that I know of. Use this as a starter. It does not handle constuctions like Select Field1 as Fieldx, but that's all I could come up with in a short time
>
>
>*---------------------------------------------------------------------------
>*--------------------------------------------------------------------------
>function View_FieldProperties_Set(ViewName)
>
>	&& view supposed to be used
>	
>	local nTables, TableList[1]
>	local nFields, FieldList[1]
>	
>	local i, j, TableFieldName, ViewFieldName, xx
>	
>	nFields = afields( FieldList, ViewName)
>	nTables = ViewTables(ViewName, @TableList)
>
>	for i = 1 to nTables
>		for j = 1 to nFields
>			
>			TableFieldName = TableList[i] + '.' + FieldList[j, 1]
>			ViewFieldName = ViewName + '.' + FieldList[j, 1]
>			
>			do case
>			case indbc(TableFieldName, 'Field')
>				
>				xx = dbgetprop(TableFieldName, 'Field', 'Caption')
>				=dbsetprop(ViewFieldName, 'Field', 'Caption', xx)
>				
>				xx = dbgetprop(TableFieldName, 'Field', 'InputMask')
>				=dbsetprop(ViewFieldName, 'Field', 'InputMask', xx)
>				
>				xx = dbgetprop(TableFieldName, 'Field', 'Format')
>				=dbsetprop(ViewFieldName, 'Field', 'Format', xx)
>			
>				xx = dbgetprop(TableFieldName, 'Field', 'DefaultValue')
>				=dbsetprop(ViewFieldName, 'Field', 'DefaultValue', xx)
>				
>			endcase
>		endfor
>	endfor
>	
>endfunc
>*--------------------------------------------------------------------------
>
>function	ViewTables(ViewName, ArrayName)
>
>	external array ArrayName
>	
>	local n, TableList
>	n = 0
>	
>	do case
>	case !indbc(ViewName, 'View')
>		&& ignore
>	otherwise
>		TableList = dbgetprop(ViewName, 'View', 'Tables')		
>		TableList = strtran(TableList, ',', chr(0x0a))
>		
>		n = alines(ArrayName, TableList, TRUE)
>		&& may hav dups, do not care
>	endcase
>	
>	return n
>endfunc
>*---------------------------------------------------------------------------
>
Thanks a Lot, this is more then enough, appreicate your help.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform