Solved

How to use Exceptional Handling in this procedure

Posted on 2013-05-24
8
239 Views
Last Modified: 2013-05-31
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go



ALTER PROCEDURE [dbo].[stp_Get_Conversation_History] --'C2OTAAC5'
      @ref_no VARCHAR(8)
AS
BEGIN
      
      SET NOCOUNT ON;

    select * from
      (
            SELECT  fbm_Id,fbm_Code,fbm_Salutation,fbm_User_Id,fbm_Name,fbm_EmailId,fbm_Mobile,fbm_IsClient,fbm_RefNo,fbm_MachineIP,
            CONVERT(varchar(6), DATEDIFF(day, fbm_Upd_Time,GETDATE())) + ' days '
            + CONVERT(varchar(6), (DATEDIFF(second, fbm_Upd_Time, GETDATE())/ 3600 % 24)) + ' hours '
            + Convert(varchar(5),RIGHT('0' + CONVERT(varchar(2), (DATEDIFF(second, fbm_Upd_Time, GETDATE()) % 3600) / 60),2))+ ' minutes ago' as fbm_Upd_Time,
            fbd_Id,fbd_Mast_Id,fbd_TypeId,fbd_AreaId,fbd_NatureId,fbd_Description,fbd_Subject_Line,fbd_StatusId,fbd_UserId,fbd_MailSent,fbd_DeptId,fbd_HandlingUserId,
            CONVERT(varchar(6), DATEDIFF(day, fbd_Upd_Time,GETDATE())) + ' days '
            + CONVERT(varchar(6), (DATEDIFF(second, fbd_Upd_Time, GETDATE())/ 3600 % 24)) + ' hours '
            + Convert(varchar(5),RIGHT('0' + CONVERT(varchar(2), (DATEDIFF(second, fbd_Upd_Time, GETDATE()) % 3600) / 60),2))+ ' minutes ago' as fbd_Upd_Time,
            fbt_Id,fbt_Type,
            convert(varchar(50),fbt_Upd_Time,100) as fbt_Upd_Time,fba_Id,fba_Area,
            convert(varchar(50),fba_Upd_Time,100) as fba_Upd_Time,fbs_Id,fbs_Status,
            convert(varchar(50),fbs_Upd_Time,100) as fbs_Upd_Time
            FROM tbl_FeedBack_Master A, tbl_FeedBack_Details B, tbl_FeedBack_Type C, tbl_Feedback_Area D,
            tbl_FeedBack_Status E
            WHERE  fbm_Id = fbd_Mast_Id
            AND fbd_TypeId = fbt_Id
            AND fbd_AreaId = fba_Id
            AND fbd_StatusId = fbs_Id
            And fbd_UserId = 0
            AND fbm_RefNo = @ref_no
            

            UNION ALL
            
            
            SELECT  fbm_Id,fbm_Code,fbm_Salutation,fbm_User_Id,Usm_User_Name as fbm_Name,'' fbm_EmailId,fbm_Mobile,fbm_IsClient,fbm_RefNo,fbm_MachineIP,
            CONVERT(varchar(6), DATEDIFF(day, fbm_Upd_Time,GETDATE())) + ' days '
            + CONVERT(varchar(6), (DATEDIFF(second, fbm_Upd_Time, GETDATE())/ 3600 % 24)) + ' hours '
            + Convert(varchar(5),RIGHT('0' + CONVERT(varchar(2), (DATEDIFF(second, fbm_Upd_Time, GETDATE()) % 3600) / 60),2))+ ' minutes ago' as fbm_Upd_Time,
            fbd_Id,fbd_Mast_Id,fbd_TypeId,fbd_AreaId,fbd_NatureId,fbd_Description,fbd_Subject_Line,fbd_StatusId,fbd_UserId,fbd_MailSent,fbd_DeptId,fbd_HandlingUserId,
            CONVERT(varchar(6), DATEDIFF(day, fbd_Upd_Time,GETDATE())) + ' days '
            + CONVERT(varchar(6), (DATEDIFF(second, fbd_Upd_Time, GETDATE())/ 3600 % 24)) + ' hours '
            + Convert(varchar(5),RIGHT('0' + CONVERT(varchar(2), (DATEDIFF(second, fbd_Upd_Time, GETDATE()) % 3600) / 60),2))+ ' minutes ago' as fbd_Upd_Time,
            fbt_Id,fbt_Type,
            convert(varchar(50),fbt_Upd_Time,100) as fbt_Upd_Time,fba_Id,fba_Area,
            convert(varchar(50),fba_Upd_Time,100) as fba_Upd_Time,fbs_Id,fbs_Status,
            convert(varchar(50),fbs_Upd_Time,100) as fbs_Upd_Time
            FROM tbl_FeedBack_Master A, tbl_FeedBack_Details B, tbl_FeedBack_Type C, tbl_Feedback_Area D,
            tbl_FeedBack_Status E,tbl_User_Master
            WHERE  fbm_Id = fbd_Mast_Id
            AND fbd_TypeId = fbt_Id
            AND fbd_AreaId = fba_Id
            AND fbd_StatusId = fbs_Id
            And fbd_UserId <>0
            and Usm_Id=fbd_UserId
            AND fbm_RefNo = @ref_no
      )X
      order by fbm_id, fbd_id

END
0
Comment
Question by:dynamicweb09
  • 3
  • 2
8 Comments
 
LVL 57

Accepted Solution

by:
Raja Jegan R earned 500 total points
ID: 39193807
Just checked the procedure script and it seems like you are performing a simple SELECT operation. SELECT operations as such doesn't require any Exception handling and hence you can ignore it.

Anyhow, since you have asked about Exceptional handling you can go through the BEGIN TRY .. CATCH statement syntaxes for your reference:

http://msdn.microsoft.com/en-us/library/ms179296%28v=sql.105%29.aspx
http://blog.sqlauthority.com/2007/04/11/sql-server-2005-explanation-of-trycatch-and-error-handling/
0
 
LVL 1

Author Comment

by:dynamicweb09
ID: 39193887
Thanks !
0
 
LVL 1

Author Comment

by:dynamicweb09
ID: 39193929
I've requested that this question be deleted for the following reason:

just like that
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 57

Expert Comment

by:Raja Jegan R
ID: 39193930
>> just like that

Kindly let me know why you are deleting the question with the above reason..
Also let me know whether you require more inputs on this question so that I can clarify accordingly.
0
 
LVL 57

Expert Comment

by:Raja Jegan R
ID: 39199080
Modulus_Twelve,

If dynamicweb09's doubt was clarified, I would request to close the question by accepting http:#a39193807 as the solution.
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 39199394
I agree.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now