我试图实现while循环我认为我的代码没问题...我的代码出了什么问题?在实现while循环时我的语法有什么问题?我是PL / SQL的新手
CREATE OR REPLACE
PROCEDURE "WHILELOOPTEST" (LIMITLOOP IN NUMBER)
AS
BEGIN
DECLARE MYCOUNTER NUMBER :=0;
WHILE MYCOUNTER < LIMITLOOP
LOOP
MYCOUNTER:= MYCOUNTER + 1;
DBMS_OUTPUT.PUT_LINE('Hello World' || MYCOUNTER);
END LOOP;
END;
答案 0 :(得分:1)
结构问题。存储过程没有DECLARE关键字。
CREATE OR REPLACE
PROCEDURE "WHILELOOPTEST"(
LIMITLOOP IN NUMBER)
AS
MYCOUNTER NUMBER :=0;
BEGIN
WHILE MYCOUNTER < LIMITLOOP
LOOP
MYCOUNTER:= MYCOUNTER + 1;
DBMS_OUTPUT.PUT_LINE('Hello World' || MYCOUNTER);
END LOOP;
END;
答案 1 :(得分:0)
您不需要在存储过程中使用DECLARE
。试试这样,
CREATE OR REPLACE
PROCEDURE WHILELOOPTEST(
LIMITLOOP IN NUMBER)
AS
MYCOUNTER NUMBER :=0;
BEGIN
WHILE MYCOUNTER < LIMITLOOP
LOOP
MYCOUNTER:= MYCOUNTER + 1;
DBMS_OUTPUT.PUT_LINE('Hello World' || MYCOUNTER);
END LOOP;
END;