문제

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;
도움이 되었습니까?

해결책

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.

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top