If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > invalid row id

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-11-03, 22:57
cjking777 cjking777 is offline
Registered User
 
Join Date: Sep 2003
Posts: 5
invalid row id

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?
Reply With Quote
  #2 (permalink)  
Old 09-12-03, 08:16
andrewst andrewst is offline
Moderator.
 
Join Date: Sep 2002
Location: UK
Posts: 5,171
Re: invalid row id

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???
__________________
Tony Andrews
http://tinyurl.com/tonyandrews
Reply With Quote
  #3 (permalink)  
Old 09-14-03, 03:28
cjking777 cjking777 is offline
Registered User
 
Join Date: Sep 2003
Posts: 5
the start_date is a date, i am just checking that the format is the same... i dont know how to change from inline...?
Reply With Quote
  #4 (permalink)  
Old 09-14-03, 07:49
andrewst andrewst is offline
Moderator.
 
Join Date: Sep 2002
Location: UK
Posts: 5,171
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.
__________________
Tony Andrews
http://tinyurl.com/tonyandrews
Reply With Quote
  #5 (permalink)  
Old 09-14-03, 18:29
cjking777 cjking777 is offline
Registered User
 
Join Date: Sep 2003
Posts: 5
thanks heaps. ill implement it today and see what happens!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On