September 17, 2014 at 4:03 am
Hoping someone maybe able to assist with this procedure.
I am trying to increase the price of an product by a user entered % for items with Dishwasher in the itemdesc.
Below is the procedure I have which doesn't appear to show any errors in the SQL Developer.
CREATE OR REPLACE PROCEDURE AdjustPrice(
pItemDesc IN ITEM.ItemDesc%TYPE,
pPercent IN NUMBER)
IS
BEGIN
UPDATE Item
SET ItemPrice = ItemPrice + ItemPrice * pPercent / 100
WHERE ItemDesc = pItemDesc;
END;
This is my run script:
BEGIN
AdjustPrice ('%Dishwasher%',10);
END;
I think the problem is with the way I have done the run script to filter to items with Dishwasher in the description. I tried LIKE an that didn't work either. Any help would be appreciated.
Thank you
September 17, 2014 at 4:38 am
CREATE PROCEDURE AdjustPrice
(
@pItemDesc VARCHAR(1000),
@pPercent NUMERIC(18,2)
)
AS
SET NOCOUNT ON
BEGIN
UPDATE Item
SET ItemPrice = ItemPrice + ItemPrice * @pPercent / 100
WHERE ItemDesc like '%@pItemDesc%'
END
EXEC AdjustPrice 'Dishwasher',10
September 20, 2014 at 6:21 am
klgould1 (9/17/2014)
Hoping someone maybe able to assist with this procedure.I am trying to increase the price of an product by a user entered % for items with Dishwasher in the itemdesc.
Below is the procedure I have which doesn't appear to show any errors in the SQL Developer.
CREATE OR REPLACE PROCEDURE AdjustPrice(
pItemDesc IN ITEM.ItemDesc%TYPE,
pPercent IN NUMBER)
IS
BEGIN
UPDATE Item
SET ItemPrice = ItemPrice + ItemPrice * pPercent / 100
WHERE ItemDesc = pItemDesc;
END;
This is my run script:
BEGIN
AdjustPrice ('%Dishwasher%',10);
END;
I think the problem is with the way I have done the run script to filter to items with Dishwasher in the description. I tried LIKE an that didn't work either. Any help would be appreciated.
Thank you
Quick question, are you on Oracle?
😎
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply