如何在pl/sql过程中读取值?

问题描述:

我在扫描pl/sql过程中的值时遇到问题.当我执行该过程时,它会忽略 a:='& a'; .

I am having problem regarding to scan a value in a pl/sql procedure. When I have execute the procedure, it ignores the a:='&a';.

程序主体

create or replace PROCEDURE Testing
IS
a VARCHAR2(3);
BEGIN
  DBMS_OUTPUT.PUT_LINE('Enter a : ');
  a:='&a';
END Testing;

过程调用

SET SERVEROUTPUT ON;
cl scr;
Execute Testing;

输出

PL/SQL procedure successfully completed.

Enter a : 

请问有人可以帮我吗??

Can anybody help me, please!?

在SQL * Plus中,我们具有提示并接受语法,但是没有直接的方法可以使PL/SQL交互而不使用PHP,Apex,Java,脚本编写.我给你脚本示例.

In SQL*Plus we have the prompt and accept syntax, but there is no direct way to make PL/SQL interactive without using PHP, Apex, Java, Scripting. I am giving you example of scripting.

例如在Windows批处理中,以下代码会有所帮助.

e.g. In Windows batch, following code will help.

1)测试程序的代码与您所拥有的相同

1) Code for the Testing procedure is same what you have

create or replace PROCEDURE  Testing (arg varchar2)
IS
a VARCHAR2(3);
BEGIN
a:=arg;
  DBMS_OUTPUT.PUT_LINE('Value of a : '||a);

END

2)test.bat

2) test.bat

sqlplus nd211/nd211 @Testing.sql te1
sqlplus nd211/nd211 @Testing.sql te4

3)Testing.sql

3) Testing.sql

set serveroutput on
exec Testing('&1');
exit;

测试; /

4)样本输出

Value of a : te1

PL/SQL procedure successfully completed.


Value of a : te4

PL/SQL procedure successfully completed.