Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to use Exceptional Handling in this procedure

Posted on 2013-05-24
8
Medium Priority
?
248 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
6 Comments
 
LVL 57

Accepted Solution

by:
Raja Jegan R earned 2000 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Viewers will learn how the fundamental information of how to create a table.

876 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