加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

oracle – 如何在运行时从用户获取输入

发布时间:2020-12-12 13:50:28 所属栏目:百科 来源:网络整理
导读:我想在oracle 10g pl / sql块(即与用户的交互式通信)中从用户那里获取运行时输入,是否可能? declarex number;beginx=x;end 此代码给出错误不能在oracle 10g中使用. 要读取用户输入并将其存储在变量中以供以后使用,可以使用sqlplus命令ACCEPT. Accept your v
我想在oracle 10g pl / sql块(即与用户的交互式通信)中从用户那里获取运行时输入,是否可能?
declare
x number;
begin
x=&x;
end

此代码给出错误&不能在oracle 10g中使用.

要读取用户输入并将其存储在变量中以供以后使用,可以使用sqlplus命令ACCEPT.
Accept <your variable> <variable type if needed [number|char|date]> prompt 'message'

accept x number prompt 'Please enter something: '

然后您可以在PL / SQL块中使用x变量,如下所示:

declare 
  a number;
begin
  a := &x;
end;
/

使用一个刺痛的例子:

accept x char prompt 'Please enter something: '

declare 
  a varchar2(10);
begin
  a := '&x';   -- for a substitution variable of char data type 
end;           -- to be treated as a character string it needs
/              -- to be enclosed with single quotation marks

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读