Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Default Field Values in a View

Status
Not open for further replies.

joepeacock

Programmer
Nov 5, 2001
74
US
I am setting up a utility for a client wherein their salespeople will be able to sync their contacts on their Pocket PCs to a database on our server using a third party utility. Each salesperson needs a separate set of data, but the company management will have web-based access to the database to be able to pull up all contacts and run reports, etc., so the model I have been creating has a table with all of the contact data. Each salesperson, then, will sync to their own view, which is simply based on the main table, with only the contacts in their territory, based on the TERRCODE field. Pretty simple and it's working so far.

Today's challenge: When a salesperson creates a new contact on their mobile device and then syncs it to the database, the new record is created in the database, but since the TERRCODE is not part of the database on the mobile device, that field is blank on the server database. Question: Can I force a default value in a view? For instance, if I create a new record in the "ST_TERRITORY" view (The view is all of the records in the contacts database with a TERRCODE value of "ST"), the TERRCODE field will autmoatically be filled with "ST". Obviuosly this is possible on a table, but how do I do it on a view?

Thanks,
Joe
 
Hi,

In your view that is customized for each road warrior you can hard code the 'ST',ST1...(if i'm understanding correctly)
Select
Col1,Col2,Col3...,
-- Example 1
'ST' as TERRCODE
-- Better yet
IsNull(TERRCODE,'ST')
--Still Better yet
IsNull(TERRCODE,(select top 1 TerrCode from MyLocalTable))
From mytableTOupdateTheServer.

Happy Hollidays
MikeD

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top