Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2004
    Posts
    9

    Unanswered: catch the error on insert or update (was "need help")

    hello!

    im new to sql... what i'm trying to do is catch the error on insert or update statment of sql.. sound simple but please..

    this is the sample table design...

    tbl_Customer

    CustomerID int(4) Primary AutoIncrement
    CustomerCode nvarchar(25)
    CustomerName nvarchar(25)
    ..
    ..
    Deleted bit(1)


    what i'm trying to do is when a record is deleted, it's not actually deleted
    in the table but only marked 1 (true) the Deleted field.. because i don't want
    to lose the relationship...

    it's easy to do this on insert statement like this..

    Create Procedure InsertCustomer(@param1 ....) AS
    IF NOT EXIST (SELECT * FROM tbl_Customer WHERE DELETED = 0) THEN
    // do insert statement here
    ELSE
    // Do nothing

    GO

    this is also easy if i create a index constraints on the table.. but this will violate my design idea..

    so anybody can help me to create the procedure in update statement and insert statement

  2. #2
    Join Date
    Feb 2004
    Location
    San Antonio, TX
    Posts
    565
    catch what error?

    can you explain what you want to do here?

Posting Permissions

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