Home » SQL & PL/SQL » SQL & PL/SQL » Executing a function from a string variable
Executing a function from a string variable [message #597263] Wed, 02 October 2013 05:27 Go to next message
lmartyn
Messages: 1
Registered: October 2013
Location: Ireland
Junior Member
Hi,

I'm trying to find a simple way of getting around this. I have a PL/SQL procedure which loops through a list of values in a table. These values are the actual names of the functions I want it to run in sequence. The problem is I can get the string value each time but I need to store the return value of each function into a number variable eg

BEGIN
open all_tests;
fetch all_tests BULK COLLECT INTO test_tabl;
close all_tests;

for myindex IN 1..test_tabl.count LOOP

time_taken := test_source1 ==> this will work but how do I avoid hardcoding the name of the function to be executed and use the test_name value instead?? time_taken is declared as a number (ie the return value of each function is a number)

test_detail := test_tabl(myindex).test_name; ==> test_detail now contains the string name of the function
dbms_output.put_line('Test detail is ' || test_detail);
end loop;

Thanks,
Louise
icon3.gif  Re: Executing a function from a string variable [message #597266 is a reply to message #597263] Wed, 02 October 2013 05:46 Go to previous message
Michel Cadot
Messages: 68645
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

execute immediate 'begin '||test_detail||'; end;' into time_taken;


Previous Topic: Modify Supertype without dropping Subtypes
Next Topic: creating the materialized view for getting the hierarchy
Goto Forum:
  


Current Time: Thu Apr 25 11:25:45 CDT 2024