Results 1 to 11 of 11

Thread: Error

  1. #1
    Join Date
    Feb 2004
    Location
    Alpine Califormia
    Posts
    1,789

    Unanswered: Error

    I am trying to learn how to create error checking in my stored procedures, and apparently I am having some problems with it can anyone help me out pls??

    Code:
    CREATE     PROCEDURE [InsertGCTerms]
    AS
    INSERT INTO [CommissionEmployee_Exclusionsdb].[dbo].[GCEmployeeTerms]([TM #],[FirstName],[LastName],[SocialSecurityNumber],[DateHired],[DepartmentName],[Title])
    SELECT a.[TM#], a.LASTNAME, a.FIRSTNAME, a.[SSN#], a.HIREDATE,
    a.[DEPT#], a.JOBTITLE FROM GOVEMPLYS AS a
    WHERE a.STATUS = 'TERMINATED'
    RETURN
    GO

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Can you coach us just a bit on what to do if an error occurs? You can always use the "panic, scream, and shout" approach, but I generally prefer something just a bit more elegant!

    -PatP

  3. #3
    Join Date
    Feb 2004
    Location
    Alpine Califormia
    Posts
    1,789

    Explain

    I was trying to use the @@ Error system function

  4. #4
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    It appears that I'm not making my question very clear. Let's go for the ever loving example, maybe that will help!
    Code:
    CREATE     PROCEDURE [InsertGCTerms]
    AS
    
    INSERT INTO [CommissionEmployee_Exclusionsdb].[dbo].[GCEmployeeTerms] (
       [TM #], [FirstName], [LastName]
    ,  [SocialSecurityNumber], [DateHired], [DepartmentName]
    ,  [Title] ) SELECT
       a.[TM#], a.FIRSTNAME, a.LASTNAME
    ,  a.[SSN#], a.HIREDATE , a.[DEPT#]
    ,  a.JOBTITLE
       FROM GOVEMPLYS AS a
       WHERE a.STATUS = 'TERMINATED'
    
    IF 0 <> @@error RAISERROR ('Scream and shout, run and panic!')
    
    RETURN
    GO
    -PatP

  5. #5
    Join Date
    Feb 2004
    Location
    Alpine Califormia
    Posts
    1,789

    Oh

    Ok sorry I see your point..LOL that was funny, need a good laugh in the morning. sorry I didnt make myself clear. But basically pat you already answered my question and now I see where I went wrong. I am so glad I ordered the http://search.barnesandnoble.com/boo...65924010&itm=1 Book this will help me out tremendously, I need a book all about programming in sql.

  6. #6
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    I would look at

    Ken Hendersons Book

    Also...did someone say error handling?

    http://weblogs.sqlteam.com/brettk/ar...5/25/1378.aspx
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  7. #7
    Join Date
    Feb 2004
    Location
    Alpine Califormia
    Posts
    1,789

    Hello Brett

    Yes I originally ordered that book but apparently it was out of stock or something, they refunded my money back got the message via email. Yes I was inquiring about Error Handling

  8. #8
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Amazon out of stock?

    I doubt it

    And did you look at my link?

    Follow the steps to save the tql file to your machine....
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  9. #9
    Join Date
    Feb 2004
    Location
    Alpine Califormia
    Posts
    1,789

    Wohoo

    ok Brett I ordered the book, those two should help me out tremendously. Thank you

  10. #10
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Great...but did you look at the error handling tql file in my blog?
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  11. #11
    Join Date
    Feb 2004
    Location
    Alpine Califormia
    Posts
    1,789

    Yes

    Yes Brett I am looking that over now thank yoiu

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •