Write a sql statement that creates a stored procedure


1- Write a SQL statement that creates a stored procedure with one int input parameter. The stored procedure selects the supplierId field and the total of all Count field values for each group of supplierId's from the Part table. The Part table was defined in week 3's assignment. Only rows with their Count total, or sum, greater than the value specified in the input parameter should be returned. Hint: Each returned record has a unique SupplierID value, since we are dealing with groups.


2- Write a SQL statement that creates a stored procedure that adds a new record to the Part table, and returns the value of the newly created PartID PK value in an out parameter. The field values of the record to be added should be passed into the stored proc as input parameters. The assumption here is that the Part table has its PartID PK field as an idendity field, or surrogate PK, meaning a numeric field that is auto-generated by the db system.


3- Write a SQL statement that creates a user defined function that returns an int value. This int return value is obtained by deducting the lowest Count field value from the highest Count field value of the Part table. You should enter dummy test records in the Part table if you are running/testing this function in SQL Server.


4- Create an Update trigger on the Part table that raises an error string if the Count field of the updated row has a higher value than the value prior to the Update. In other words, the new value cannot be larger than the older value. If the trigger fires and after the error string is displayed, the Update operation should be rolled back. The exact text of the error string is up to you to define.

Request for Solution File

Ask an Expert for Answer!!
PL-SQL Programming: Write a sql statement that creates a stored procedure
Reference No:- TGS0143002

Expected delivery within 24 Hours