Professional Documents
Culture Documents
--------------------------------------------------------------------------------
-------
CREATE FUNCTION [dbo].get_contactlist
(@acode varchar(30),@opt varchar(1))
RETURNS varchar(500) AS
BEGIN
DECLARE @str varchar(500),@str1 varchar(150)
if @opt='P'
DECLARE tc1 CURSOR LOCAL FOR
SELECT cont_pers+'- '+(case isnull(mobile,'') when '' then isnul
l(phone,'') else isnull(mobile,'') end) as cont
FROM cont_person where acode=@acode ORDER BY cont_pers
else
DECLARE tc1 CURSOR LOCAL FOR
SELECT cont_pers+(case isnull(email,'') when '' then '' else ' (
'+isnull(email,'')+')' end) as cont
FROM cont_person where acode=@acode ORDER BY cont_pers
SET @str=''
OPEN tc1
FETCH NEXT FROM tc1 INTO @str1
while @@fetch_status=0
begin
if len(@str)<>0
SET @str=@str+char(13)
SET @str=@str+@str1
FETCH NEXT FROM tc1 INTO @str1
end
CLOSE tc1
DEALLOCATE tc1
RETURN @str
END
GO
--------------------------------------------------------------------------------
-------
ALTER PROCEDURE mail_cust
@id numeric,@mailopt varchar(10)
AS