Cindy
asked on
Modifying Stored Procedure
I need to Modify the ADD_CUSTOMER procedure below so that it takes a fourth CUST_BALANCE IN argument, including modifying the INSERT statement so that it inserts the value passed in instead of the zero above. The stored procedure is below.
Please provide assistance - I continue to get error messages
CREATE PROCEDURE ADD_CUSTOMER -- Create a new customer
@cus_id_arg NUMERIC, -- This parameter is the new customer's ID.
@first_name_arg VARCHAR(30), -- This parameter is the new customer’s first name.
@last_name_arg VARCHAR(40) -- This parameter is the new customer's last name.
AS -- This "AS" is required by the syntax of stored procedures.
BEGIN
-- Insert the new customer with the parameters given, and a 0 balance.
INSERT INTO CUSTOMER (CUSTOMER_ID,CUSTOMER_FIRS T,CUSTOMER _LAST,CUST OMER_TOTAL )
VALUES(@cus_id_arg,@first_ name_arg,@ last_name_ arg,0);
END;
Please provide assistance - I continue to get error messages
CREATE PROCEDURE ADD_CUSTOMER -- Create a new customer
@cus_id_arg NUMERIC, -- This parameter is the new customer's ID.
@first_name_arg VARCHAR(30), -- This parameter is the new customer’s first name.
@last_name_arg VARCHAR(40) -- This parameter is the new customer's last name.
AS -- This "AS" is required by the syntax of stored procedures.
BEGIN
-- Insert the new customer with the parameters given, and a 0 balance.
INSERT INTO CUSTOMER (CUSTOMER_ID,CUSTOMER_FIRS
VALUES(@cus_id_arg,@first_
END;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
if you are modifying sa stored proc make sure you replace the "CREATE" with "ALTER"
ASKER
How do I add a row to the store procedure?
What type of row do you want to add? Please elaborate.
ASKER
I have another table called the Item's Table with Item_ID, Item_description, Item_Price. I need to create a stored procedure that will add additional item row? I attempted to creat the procedure and received number error messages
Here is what I created: When I execute I receive error message: Msg 102, Level 15, State 1, Procedure ADD_ITEM, Line 4 Incorrect syntax near 'NUMERIC'.
What am I doing wrong? Thanks
CREATE PROCEDURE ADD_ITEM -- Create a new item
@item_id_arg NUMERIC, -- This parameter is the new item ID.
@item_description_arg VARCHAR(30), -- This parameter is the item description.
@item_price NUMERIC -- This parameter is the item price.
AS -- This "AS" is required by the syntax of stored procedures.
BEGIN
-- Insert the new customer with the parameters given, and a 0 balance.
INSERT INTO item (item_ID,item_description, item_price)
VALUES(@item_id_arg,@item_ descriptio n_arg,@ite m_price_ar g,0);
END;
Here is what I created: When I execute I receive error message: Msg 102, Level 15, State 1, Procedure ADD_ITEM, Line 4 Incorrect syntax near 'NUMERIC'.
What am I doing wrong? Thanks
CREATE PROCEDURE ADD_ITEM -- Create a new item
@item_id_arg NUMERIC, -- This parameter is the new item ID.
@item_description_arg VARCHAR(30), -- This parameter is the item description.
@item_price NUMERIC -- This parameter is the item price.
AS -- This "AS" is required by the syntax of stored procedures.
BEGIN
-- Insert the new customer with the parameters given, and a 0 balance.
INSERT INTO item (item_ID,item_description,
VALUES(@item_id_arg,@item_
END;
Change '@item_price NUMERIC' to '@item_price_arg NUMERIC' and remove the 0 on the INSERT statement. These changes should fix it.
If you have related questions, please open another Question.
Thanks.
If you have related questions, please open another Question.
Thanks.
Please use same datatype as input parameter in stored procedure: ADD_CUSTOMER
Before writing stored procedure, please matched the datatype in table and accept as same data type. You can also type cast, but it will make more complex.
If datatype is Money, you can use the SP posted by wdosanjos.
If Datatype is decimal: Use this stored procedure.
Or just verify what is exact datatype and use same.
Open in new window