with this code:
SET SERVEROUTPUT ON
CREATE OR REPLACE
PROCEDURE update_price(p_cutoff IN CHAR) AS
change CONSTANT Real := 0.9;
CURSOR c_upgrade_p IS
SELECT price FROM (select price, start_date from items i, on_sale os
WHERE (i.id = os.item_id))
WHERE (TO_DATE(start_date,'DD-MON-YYYY') = TO_DATE(p_cutoff,'DD-MON-YYYY'))
FOR UPDATE OF PRICE;
BEGIN
FOR record IN c_upgrade_p LOOP
UPDATE items
SET price = price * 0.9
WHERE CURRENT OF c_upgrade_p;
END LOOP;
COMMIT;
END;
/
exec update_price('30-AUG-03');
i get an invalid row id error, why is this?Try it without the inline view:
CURSOR c_upgrade_p IS
SELECT price
from items i, on_sale os
WHERE (i.id = os.item_id))
WHERE (TO_DATE(start_date,'DD-MON-YYYY') = TO_DATE(p_cutoff,'DD-MON-YYYY'))
FOR UPDATE OF PRICE;
BTW, does this: TO_DATE(start_date,...) mean that start_date is not a DATE?|||the start_date is a date, i am just checking that the format is the same... i dont know how to change from inline...?|||If start_date is a DATE, then don't use TO_DATE on it. And I showed you the version without the inline view, though I made a mistake or two. Here is the corrected version, with the unwanted TO_DATE removed:
CURSOR c_upgrade_p IS
SELECT price
from items i, on_sale os
WHERE i.id = os.item_id
AND start_date = TO_DATE(p_cutoff,'DD-MON-YYYY')
FOR UPDATE OF PRICE;
A DATE column doesn't have any format, it is stored in a special internal coding. Only use TO_DATE to convert a text string to a DATE, and use TO_CHAR to format a DATE for display.|||thanks heaps. ill implement it today and see what happens!
Showing posts with label replaceprocedure. Show all posts
Showing posts with label replaceprocedure. Show all posts
Monday, March 26, 2012
invalid row id
Labels:
c_upgrade_p,
char,
codeset,
constant,
cursor,
database,
invalid,
microsoft,
mysql,
oncreate,
oracle,
p_cutoff,
real,
replaceprocedure,
row,
server,
serveroutput,
sql,
update_price
Subscribe to:
Posts (Atom)