I'm looking to add some lookup lists in the database, but I want them to be easy localizable (SQL 2005, ADO.NET)
This would include:
- Easy Management of multiple languages at the same time
- Easy Retrieval of values from the database
- Fallback language (in case the selected language is missing)
I was thinking about having a table that would store the multi-language lookup-list (using for different languages the same id) and use a function that would return the value of the look-up list - by receiving the ID and the Language.
One of the pitfalls would be that i have to manually add a language parameter to every query that uses the lookup list.
I'm looking into a solution that would let me send the parameter as a "session/global variable", or that would send the parameter automatically with the sql query, and the function to retrieve it by itself (either to attach the parameter automatically, either to be able to read the parameter).
The solution can look something like this, but I don't mind if it is different, as long as it doesn't give the parameter explicitly to the Query (pseudocode):
1. Send the language using "the method" 2. Execute Query 3. Get the localized results
Clarification:
Normally the query would look like this (remember using the lookup function):
SELECT .., GetLookupList1(lookup_ID, language), .. FROM TABLE
The GetLookupList1 is a user defined function that retrieves the lookup value for a lookup table. By using this function, the SQL Code is easier to read and maintain.
The body of the function would be something like:
SELECT @result = LookupValue FROM LookupTable1 WHERE ID=@Lookup_ID and Language=@lang
RETURN @result
What I want is to be able to remove the language parameter from the function to some kind of a static variable, available only for the current connection/statement/command, so the query would look like
SELECT .., GetLookupList1(lookup_ID), .. FROM TABLE