Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
JTProg
Starting Member
24 Posts |
Posted - 2006-09-15 : 16:00:29
|
| How can I make this procedure to only allow an identical @LineItem or null each time, and nothing else? If it is something else, I want to return a message to the user stating values have to be identical after an initial entry has been made instead of running the insert command. This is not a default. Each batch can have a range(g2, g3, g4, g5) of values, but once a value from that range has been identified it should remain the same for that batch.CREATE PROCEDURE dbo.procInsertSingle@ID Nvarchar(8),@Type Nvarchar(20),@LineItem Nvarchar(5),@ResultMessage Nvarchar(50) OUTPUTAS IF EXISTS(Select LineItem from dbo.Line Where ID = ID and LineItem = @LineItem)BEGINBEGIN TRAN INSERT INTO dbo.Line ( Name, Type, LineItem) VALUES ( @Name, @Type, @LineItem)ENDELSEBEGIN Select @ResultMessage = 'values have to be identical after an initial entry'ENDGO |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-09-19 : 05:32:02
|
| First I thinkIF EXISTS(Select * from dbo.Line Where ID = ID and LineItem = @LineItem)should beIF EXISTS(Select * from dbo.Line Where ID = @ID and LineItem = @LineItem)Now you have to clarify your objective...Peter LarssonHelsingborg, Sweden |
 |
|
|
|
|
|
|
|