Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2004-12-09 : 08:52:17
|
| ctranx writes "How do I write a user defined function that validate against the form's drop down month and year.scenario:input paramenter (1204_08.01.01_tranc)12 - December04 - 2004_08.01.01_tranc - irrevelant right now but they are _project and _user nameIf the input parameter 1204 doesn't matched with December and/or 2004 (both) I want to state the reason of 'Month Mismatch'.So far I had created this case statement and it worked fine with checking for valid form of 1204 or 1104. Not December2004 or Nov 04. Right now I'm stuck at this point about validating against form's month and/or year drop down.alter function PHA_MONTH_TEST_FCT( @act_name nvarchar(64))returns nvarchar(64)asbegindeclare @v_name_month nvarchar(64)declare @v_name_check_month nvarchar(64)declare @v_name_invalid nvarchar(64)declare @v_name_inv_month nvarchar(64)select @v_name_invalid = 'Invalid Form Name'select @v_name_inv_month = 'Month Mismatch'select @v_name_month = case when substring(@act_name, 1, 2)like '01' then 'January' when substring(@act_name, 1, 2)like '02' then 'February' when substring(@act_name, 1, 2)like '03' then 'March' when substring(@act_name, 1, 2)like '04' then 'April' when substring(@act_name, 1, 2)like '05' then 'May' when substring(@act_name, 1, 2)like '06' then 'June' when substring(@act_name, 1, 2)like '07' then 'July' when substring(@act_name, 1, 2)like '08' then 'August' when substring(@act_name, 1, 2)like '09' then 'September' when substring(@act_name, 1, 2)like '10' then 'October' when substring(@act_name, 1, 2)like '11' then 'November' when substring(@act_name, 1, 2)like '12' then 'December' else @v_name_invalidendif @v_name_month = @v_name_invalid or @v_name_year = @v_name_invalid return @v_name_invalid ***No return value yet because that's where I'm stuck.I had try the following but I'm keep getting this error 'The last statement included within a function must be a return statement'.select @v_name_check_month = a.lookup_code from niku.cmn_lookups a where a.lookup_type = 'PRJ_UPDATE_MONTH' and a.lookup_code = @v_name_monthif @v_name_check_month = @v_name_month-- select @v_name_inv_month = ''--else return @v_name_inv_monthend" |
|
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2004-12-10 : 00:47:39
|
this validation should be handle at the application layer and pass the parameters as valid already --------------------keeping it simple... |
 |
|
|
|
|
|
|
|