SQL*Plus how to accept text variable from prompt?(SQL*Plus 如何从提示中接受文本变量?)
问题描述
我是 psql 的初学者,我有一个问题.
Im very beginner in psql and i have a question.
代码如下:
SET serveroutput ON
ACCEPT myVariable PROMPT "Input value: ";
BEGIN
dbms_output.put_line('My input variable is: '||&myVariable);
END;
问题很简单:如何将文本传递给我的变量?如果我输入一个数字,它可以正常工作并且我可以在日志中读取我的数字,但是如果我传递像mytext"这样的文本而不是数字,我会收到一个错误:
Question is very simple: How can i pass text to my variable? If i input a number it is works correctly and i can read in the log my number, but if i pass a text like "mytext" instead of a number, i got an error:
old:BEGIN
dbms_output.put_line('My input variable is: '||&myVariable);
END;
new:BEGIN
dbms_output.put_line('My input variable is: '||mytext);
END;
Error starting at line 5 in command:
BEGIN
dbms_output.put_line('My input variable is: '||&myVariable);
END;
Error report:
ORA-06550: 2 sor, 50 oszlop:
PLS-00201: identifier 'MYTEXT' must be declared
ORA-06550: 2 sor, 3 oszlop:
PL/SQL: Statement ignored
06550. 00000 - "line %s, column %s:
%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
推荐答案
您必须指定数据类型作为 接受声明.如果没有给出,则假定一个数字.
You have to specify the data type as part of the ACCEPT statement. If none is given, it assumes a number.
尝试 ACCEPT myVariable CHAR PROMPT 'Input value: '; 代替.
这篇关于SQL*Plus 如何从提示中接受文本变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:SQL*Plus 如何从提示中接受文本变量?
基础教程推荐
- 二进制文件到 SQL 数据库 Apache Camel 2021-01-01
- 什么是 orradiag_<user>文件夹? 2022-01-01
- 表 './mysql/proc' 被标记为崩溃,应该修复 2022-01-01
- oracle区分大小写的原因? 2021-01-01
- MySQL 中的类型:BigInt(20) 与 Int(20) 2021-01-01
- 如何在 SQL 中将 Float 转换为 Varchar 2021-01-01
- mysql选择动态行值作为列名,另一列作为值 2021-01-01
- 在 MySQL 中:如何将表名作为存储过程和/或函数参数传递? 2021-01-01
- 如何根据该 XML 中的值更新 SQL 中的 XML 2021-01-01
- 在多列上分布任意行 2021-01-01
