|
|
 |
| SQL Server 2005 General discussion of SQL Server *2005* version only. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the SQL Server 2005 section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
|
 |

April 8th, 2008, 09:11 AM
|
|
Authorized User
|
|
Join Date: Mar 2008
Location: , , .
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Stored Procedures help
Hey,
I need to write two stored procedures and link them to a button on a web form. Basically I have a web form called OrderAllocation.aspx This form takes orders and allocates them to ships (Orders and Ships being two different tables). This "allocation" involves adding the select order and ship to a new table called OrdersonShip. I need to write the two stored procedures so that 1) I can get that the Ship has space to take the order and that the ship isn't full already. 2) If the ship is able to take the order insert a new line in the OrdersonShip table (consisting of the ShipID and OrderID) and then add the value of the order (NumofItems) to the currentnumofCargo of the ship in the Ship table. To me it sounds horribly complicated, but I have no idea how to start. I have looked at a few guides online but they don not seem to help, or they don't go as indepth as I need them to.
Below is a link which shows my database diagram.
http://img396.imageshack.us/img396/8...diagramtn6.jpg
Many thanks for any help, it's driving me mad working our where I should start and what to do to complete this task.
Peter
|

April 8th, 2008, 07:36 PM
|
|
Wrox Author
Points: 12,827, Level: 49 |
|
|
Join Date: Oct 2005
Location: Akron, Ohio, USA.
Posts: 4,029
Thanks: 1
Thanked 42 Times in 42 Posts
|
|
Not sure how this equates to two sprocs. Without knowning any of the business rules of your database, I assume, something like this would work:
CREATE PROCEDURE usp_ShipOrder
(
--Any Params
)
AS
if (SELECT Sum(NumberofCargo - CurrentNumOfCargo) From Ship where ShipID = value) > 0
Begin
--Space is available on the ship, add the record
End
Else
Begin
--Space is not available on the ship, exit
End
Does that make sense?
================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor / Author :.
Wrox Books 24 x 7
================================================== =========
|

April 12th, 2008, 02:31 AM
|
|
Friend of Wrox
|
|
Join Date: Aug 2004
Location: Orange County, CA, USA.
Posts: 385
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
you need to give more info if you want more help......
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |