Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


How to insert in 3 tables using stored procedure


How to insert in 3 tables using stored procedure

Author
Message
enriquezreyjoseph
enriquezreyjoseph
SSC Journeyman
SSC Journeyman (79 reputation)SSC Journeyman (79 reputation)SSC Journeyman (79 reputation)SSC Journeyman (79 reputation)SSC Journeyman (79 reputation)SSC Journeyman (79 reputation)SSC Journeyman (79 reputation)SSC Journeyman (79 reputation)

Group: General Forum Members
Points: 79 Visits: 191
L' Eomot Inversé (9/21/2013)
AndrewSQLDBA (9/20/2013)
This code is a waste, since @FirstName is an input parameter that will not allow a NULL. And the front-end should be checking the values for blanks, not the database.

IF @firstname = ''
BEGIN
RAISERROR ('[Error]No first name', 16, 1)
RETURN
END


If that variable from the front-end gets all the way to the database with a blank space, you need to look at the code on the front-end.

I would recommend that you keep that code - relying on the front end to enforce domain constraints is a mistake. You should also have the column in the table declared
FirstName varchar(50) NOT NULL CHECK(LEN(FirstName) > 0)
since that's how domain constraints are expressed in T-SQL and you should want our tables to be in 1NF, which means the table definition must specify the domain of each attribute. Since the NULL values and zero length strings are not in the domain of this attribute, the table definition should say so.
Of course it's a good idea to have the front end check these things too - it can usually give a quicker and better response to a user who makes a mistake that it detects than if it lets the mistake through for the database to detect. But that doesn't absolve the database from responsibility for data integrity.


Thanks Tom...you are so great :-)..cheers!!!
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search