PL/SQL: how do i prompt user input in a procedure?

前端 未结 4 2005
渐次进展
渐次进展 2020-12-09 23:26

This is a question about a small part of a large project I\'m doing. I tried the following but I just get the two errors below it:

SET SERVEROUTPUT ON

CREAT         


        
4条回答
  •  心在旅途
    2020-12-10 00:02

    This piece of code works only in SQL*Plus and can't be used to produce a stored procedure!!!

    DECLARE
    variable1 NUMBER(1);
    variable2 CHAR(1);
    
    BEGIN
    DBMS_OUTPUT.PUT_LINE('Hello World');
    variable1 := &please_enter_1_or_0;
    variable2 := '&please_enter_y_or_n';
    END;
    

    Mind the difference in the last statement where the last substitution variable is quoted in a string to be properly accepted by the PL/SQL syntax. Anyway, as I told you in the last comment to your question this is not a user interaction but just the result of a statement preprocessing. Every time you input different values the RDBMS executes a different source code.

    Probably your requirement to use a "procedure" doesn't meant to use a STORED procedure(that is impossible to do so), but they just intended a SQL*Plus script, ask for clarifications.

提交回复
热议问题