SQL*Plus how to accept text variable from prompt?

雨燕双飞 提交于 2019-11-27 05:28:57

You have to specify the data type as part of the ACCEPT statement. If none is given, it assumes a number.

Try ACCEPT myVariable CHAR PROMPT 'Input value: '; instead.

You have to enclose the character substitution variable in quotes when you use it, if it's a string, otherwise Oracle tries to interpret the value as an object name. You can see that on the 'new' version (shown because you have set verify on), and sexta13 alluded to that too. So you would do:

 dbms_output.put_line('My input variable is: '||'&myVariable');

But you don't need to concatenate the value in this case (whether it's a number or s string):

 dbms_output.put_line('My input variable is: &myVariable');

You don't have MYTEXT variable declared anywhere.

dbms_output.put_line('My input variable is: '||mytext); -- here is the error. It should be &myVariable.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!