p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > SQL Server > SQL Server 2005 > SQL Server 2005
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 8th, 2008, 09:11 AM
Authorized User
 
Join Date: Mar 2008
Location: , , .
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old April 8th, 2008, 07:36 PM
Wrox Author
Points: 12,827, Level: 49
Points: 12,827, Level: 49 Points: 12,827, Level: 49 Points: 12,827, Level: 49
Activity: 15%
Activity: 15% Activity: 15% Activity: 15%
 
Join Date: Oct 2005
Location: Akron, Ohio, USA.
Posts: 4,029
Thanks: 1
Thanked 42 Times in 42 Posts
Send a message via AIM to dparsons
Default

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
================================================== =========
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #3 (permalink)  
Old April 12th, 2008, 02:31 AM
Friend of Wrox
Points: 807, Level: 11
Points: 807, Level: 11 Points: 807, Level: 11 Points: 807, Level: 11
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2004
Location: Orange County, CA, USA.
Posts: 385
Thanks: 0
Thanked 0 Times in 0 Posts
Default

you need to give more info if you want more help......

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Stored Procedures KeviJay VB Databases Basics 1 June 5th, 2008 08:17 AM
stored procedures MunishBhatia SQL Server 2005 4 April 12th, 2008 02:39 AM
STORED PROCEDURES shazia1 SQL Server ASP 7 September 26th, 2007 07:11 AM
Stored Procedures itHighway SQL Server 2000 3 November 23rd, 2005 10:08 AM
Stored Procedures stu9820 Access 3 February 8th, 2004 01:13 PM



All times are GMT -4. The time now is 04:10 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc