Problem with a PL/SQL script. FOR....LOOP
Date: 2000/04/19
Message-ID: <8dk5dc$98k$1_at_news.inet.tele.dk>#1/1
Hi all.
I have a problem that is driving me crazy. The problem is in the following PL/SQL script, and more exact in the linies were I have put the * marks.
OK. The problem is, that I want to transfer the value of the variabel 'CompNr' to the CURSOR through the FOR LOOP. But somehow that is just not possible.
The value of 'CompNr' is not vissible from the FOR LOOP. If I type a number instead of 'CompNr' in the FOR LOOP there is no problem handle it, but as soon as I want to use the variable in the FOR LOOP the problem beginnings. How can I access the value of CompNr from the FOR LOOP and send it to the CURSOR.
I really hope someone can help me.
If someone prefer to mail then do it to this address:
henrikfrisk_at_hotmail.com
/***************************************************************************
*************/
CREATE OR REPLACE FUNCTION SQLTEST(FaaNr IN CHAR) RETURN NUMBER IS MachinePrice NUMBER(7,2);
CompNr CHAR(25);
CURSOR SparePart_Cur(Curvar CHAR) IS
SELECT ChildTypeNr, Quantity
FROM SparePartComb
WHERE ParentTypeNr = Curvar;
BEGIN
MachinePrice := 0; * CompNr := 'F5920003'; * FOR Spare_rec IN SparePart_Cur(CompNr) LOOP MachinePrice := (Spare_rec.ChildTypeNr * Spare_rec.Quantity);END LOOP; RETURN MachinePrice;
END SQLTEST;
/
SHOW ERRORS;
/***************************************************************************
****************/Received on Wed Apr 19 2000 - 00:00:00 CEST