Thursday, June 11, 2009

Procedure

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER procedure [dbo].[focommison](@foid varchar(50),@amt decimal(20,2))
as begin
declare @id varchar(50)
declare @qu varchar(10)
select @id = (select fo_id from tblfcm where emp_code in(select emp_code from tblFO where fo_id=@foid))
select @qu=(select q_no from tblquarter where getdate() between start_date and end_date )
declare @com decimal(20,2)
select @com=@amt*20/100
if @id is not null
begin
print @id
insert into tblcommision_details values (@id,getdate(),@com,@qu)
update tblcommision set amount=convert(decimal(20,2),amount)+ @com where emp_code=@id and q_id=@qu
exec focommison @id,@com
end
end

No comments:

Post a Comment