PLSQL 命令行参数
我有一个testing.sql 程序。第一个列表行我使用 define run_date = '&1'
接收命令行参数,并在光标中使用它。
参数我希望它作为字符串 '24/02/2011'
并且我在 sql 查询和游标中使用它进行比较。
Select *
from bill_file b
where to_char(b.initial_process_date_time,'DD/MM/YYYY')=&run_date;
当我从 sqlplus 调用脚本时,它给出了错误。不确定如何接收字符串参数。
这是我尝试的方法:
SQL> @testing.sql 24/02/2011
I am having a testing.sql program. First list line I receive the command line argument with define run_date = '&1'
and use it in cursor.
Argument I want it as string '24/02/2011'
and I use it in comparison in sql queries and cursors.
Select *
from bill_file b
where to_char(b.initial_process_date_time,'DD/MM/YYYY')=&run_date;
When I call the script from sqlplus it's giving errors. Not sure how I can receive string arguments.
Here is how I tried:
SQL> @testing.sql 24/02/2011
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
非常感谢您提供的信息。我将 run_date 用单引号括起来,它起作用了。
Select * from bill_file b where to_char(b.initial_process_date_time,'DD/MM/YYYY')='&run_date';
Thanks a lot for the info. I enclosed the run_date in single quotes and it worked.
Select * from bill_file b where to_char(b.initial_process_date_time,'DD/MM/YYYY')='&run_date';
您忘记了引号
@testing.sql "24/02/2011"
You forgot quotes
@testing.sql "24/02/2011"
如果没有您所做的全部事情,我们无法说。
它的工作原理如下(调用中不带引号,但在
to_date
中):Without the entirety of what you did, we can't say.
Here is how it simply works (without quotes in the call, but in the
to_date
):