stored procedure for updating data
604514Oct 22 2007 — edited Oct 23 2007Hello, I am new to pl/sql and have spent one day to try to make a stored procedure work, but no luck so far. Maybe my limited brain capability is a major key obstacle in this issue?! :-)
Anyway, I would really like to get some input to how I can make this code compile and work. I am using sql developer 1.2.1 on an oracle database.
Before I post the code I will explain my need/what I want to accomplish:
An already existing table holds data (number format) in a column (say column c). I will divide a fixed value with the data in column c and insert this new value into another existing table. For example, the fixed value is 9.81, divide that with the data in column c (this process is done for every row by the way), so for instance 9.81 / 6.23, put this new number in a column in another table, and then take the next row and so on. Quite simple when speaking about it but I have not mastered the pl/sql syntax yet.
Ok, here is my attempt at the code:
create or replace PROCEDURE convert_fx_rate AS
fx_rate_fixed NUMBER;
counter NUMBER;
temp2 NUMBER;
BEGIN
fx_rate_fixed :=
(SELECT fx_rate_internal
FROM temp_fx_rate
WHERE cur_cross_name = 'USD/SEK')
;
counter := 0;
FOR counter < COUNT(temp_fx_rate) counter := counter + 1;
temp2 :=
(SELECT fx_rate_internal
FROM temp_fx_rate
WHERE rownum = counter)
;
UPDATE fx_rate_internal :=(fx_rate_fixed / temp2)
FROM temp_fx_rate
WHERE rownum = counter;
END LOOP;
DBMS_OUTPUT.PUT_LINE
END convert_fx_rate;
From this I get 6 error messages, they are quite long ones but their codes are Error(8,6)
Error(10,38)
Error(13,15)
Error(13,37)
Error(15,6)
Error(17,28)
I would appreciate any comments and help, really much, thanks in advance.
Harald