sql server - t-sql procedure has no errors but need to be enhanced -


i have written procedure in t-sql returns errorcount based on state code,fiscal year etc..., has 3 pieces involved: 1. returns inner join of 2 tables pull selective columns 2. case statement multiple value possibility coloffset 3. function return errorcount.

when run code gives output 3 separate tables, but, intend errorcount output. how can accomplish this. oracle equivalent used cursor. need use here?

here's code:

alter procedure [hsip].[errorcount] (     @cregion char(2) ='00',     @cstate_code char(2) = '00',     @nfy numeric(4,0) = 0,     @nreport_id numeric(2,0) = 0,     @nsection_id numeric(2,0) = 0,     @nsubsection_id numeric(2,0) = 0,     @ndisplay_number numeric(38,0) = 0,     @nquestion_number numeric(38,0) = 0,     @nquestion_part_number numeric(38,0) = 0,     @suser_id varchar(25) =null,    @nfy_st_question_dtl_table_id numeric(38,0))   begin      set nocount on;  --declare nfy_st_question_dtl_table_id integer  --declare ncolumn_index cursor declare @coloffset integer --@temptbl numeric(38,0)   select qi.region, qi.state_code, qi.fy, qi.report_id, qi.section_id, qi.subsection_id, qi.display_number, qi.question_number, qd.question_part_number  fy_st_question_detail qd inner join fy_st_question_info qi on qd.fy_st_question_info_table_id =  qi.fy_st_question_info_table_id qi.region = @cregion          , qi.state_code = @cstate_code          , qi.fy = @nfy          , qi.report_id = @nreport_id          , qi.section_id = @nsection_id          , qi.subsection_id = @nsubsection_id          , qi.display_number = @ndisplay_number          , qi.question_number = @nquestion_number          , ( qi.reporter_id = @suser_id or                qi.delegate_id = @suser_id or                qi.sub_delegate_id = @suser_id )          , qd.question_part_number = @nquestion_part_number ;           set @coloffset=             case            when (@nreport_id = 1 , @nquestion_number = 21)  17             when (@nreport_id = 1 , @nquestion_number = 32)  16             when (@nreport_id = 3 , @nquestion_number = 11)  15             when (@nreport_id = 3 , @nquestion_number = 12)  27         end;       select [hsip].[geterrorcount](@nfy_st_question_dtl_table_id, 0, @coloffset)as errcount;      end 

thanks,

comment out or delete select statements generate tables don't want in output.


Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -