Hi
I have a cursor that is an ordinary select statement, I open the cursor, and perform an update within each loop of the cursor, however in the update I use a substitution variable. When I run this script, it works, however it prompts the user for the substitution variable once and uses that value in each loop of the cursor - I could do this in a different way perhaps through unix shell&sql or simpler sql- but I was just wondering why this didn't work ?
DECLARE CURSOR ChargeQuery IS
Select sb.servicebundleid,o.operatorid,sb.bundlename,sb.bundlecharge
from service_bundles sb,operator o;
vbundleid number;
vbundlename varchar2(40);
vbundlecharge number;
vopid number;
BEGIN
OPEN ChargeQuery;
LOOP
FETCH ChargeQuery INTO vbundleid,vopid,vbundlename,vbundlecharge;
EXIT WHEN ChargeQuery%NOTFOUND;
BEGIN
Update service_bundles
set bundlecharge=&icharge
where servicebundleid=vbundleid
and operatorid =vopid;
END;
END LOOP;
CLOSE ChargeQuery;
END;
/
thanks
Martha [sig][/sig]
I have a cursor that is an ordinary select statement, I open the cursor, and perform an update within each loop of the cursor, however in the update I use a substitution variable. When I run this script, it works, however it prompts the user for the substitution variable once and uses that value in each loop of the cursor - I could do this in a different way perhaps through unix shell&sql or simpler sql- but I was just wondering why this didn't work ?
DECLARE CURSOR ChargeQuery IS
Select sb.servicebundleid,o.operatorid,sb.bundlename,sb.bundlecharge
from service_bundles sb,operator o;
vbundleid number;
vbundlename varchar2(40);
vbundlecharge number;
vopid number;
BEGIN
OPEN ChargeQuery;
LOOP
FETCH ChargeQuery INTO vbundleid,vopid,vbundlename,vbundlecharge;
EXIT WHEN ChargeQuery%NOTFOUND;
BEGIN
Update service_bundles
set bundlecharge=&icharge
where servicebundleid=vbundleid
and operatorid =vopid;
END;
END LOOP;
CLOSE ChargeQuery;
END;
/
thanks
Martha [sig][/sig]