Question

In oracle procedure i want to take input in for loop it is possible or not

DECLARE
   x NUMBER := 0;
BEGIN
   FOR i IN 1..10 LOOP
    //Here i want to take 10 time input from user and print its sum. It is possible or not
   END LOOP;
   COMMIT;
END;
Was it helpful?

Solution

It's not. PL/SQL runs on the database server. It has no access to user input whether inside or outside of a loop.

You can write a SQL*Plus script that includes 10 substitution variables, prompts the user for values, builds a PL/SQL block that computes the sum, and then submits the PL/SQL block to the database to be executed. That will only work, though, if the caller is an application like SQL*Plus that has the ability to use substitution variables.

OTHER TIPS

What about (1) storing user input into the database; and then (2) run the procedure which to process them.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top