如何在pl/sql过程中读取值? [英] How read a value in pl/sql procedure?

查看:196
本文介绍了如何在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.

这篇关于如何在pl/sql过程中读取值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆