Reference no: EM132154446
Two students may work together on this project and only one person needs to submit the work. Please make sure you include both names on this document. Students will be required to demonstrate to me during the week of Nov 28 that they have made progress on the actual code. This may be done in class or by appointment.
Stored Procedure Exercise
Write a stored procedure using transactional processing that inserts a new row into the Vendor table and then adds at least one new Invoice for that new Vendor. This program must include the ability to handle a failed transaction in which case it should issue an error message and a rollback.
Invoices: Orders.ShipName, Orders.ShipAddress, Orders.ShipCity, Orders.ShipRegion, Orders.ShipPostalCode,
Orders.ShipCountry, Orders.CustomerID, Customers.CompanyName AS CustomerName, Customers.Addres, Customers.City, Customers.Region, Customers.PostalCode, Customers.Country,
InvoiceLineItem:
For the Vendor table the required columns are
[VendorName] [varchar](50) NOT NULL
[VendorCity] [varchar](50) NOT NULL
[VendorState] [char](2) NOT NULL
[VendorZipCode] [varchar](20) NOT NULL
Make sure you allow for a value for the Defaulted Columns, but these values should be optional as the database has predefined the default value is none is supplied.
[DefaultTermsID] [int] NOT NULL (acceptable values are 1, 2, 3, 4, or 5 with 3 being the default)
ALTER TABLE [dbo].[Vendors] ADD CONSTRAINT [DF_Vendors_TermsID] DEFAULT ((3)) FOR [DefaultTermsID] - this is the code that was used in the table definition that actually set the default value for the DefaultTermsID.
[DefaultAccountNo] [int] NOT NULL (there are 75 possible account values with 570 being the default)
ALTER TABLE [dbo].[Vendors] ADD CONSTRAINT [DF_Vendors_AccountNo] DEFAULT ((570)) FOR [DefaultAccountNo] - this is the code that was used in the table definition that actually set the default value for the DefaultAccountNo
Although VendorID (which is the Primary Key) is required for the table, you do not have to supply a value for this since it is an IDENTITY column which means the value is autogenerated.