我知道如何通过单个命令行执行存储过程
echo execute some_procedure | sqlplus用户名/密码@ databasename但我困在程序中传递IN参数,取两个参数。 我尝试了但不工作
echo execute some_procedure(123,234) sqlplus username / password @ databasename如果有人可以帮助我。 p>
解决方案您显示的内容中,您需要转义括号:
echo execute some_procedure\(123,234\)| sqlplus username / password @ databasename或将命令括在双引号中:
echoexecute some_procedure(123,234)| sqlplus username / password @ databasename要么会阻止shell试图提取parathenses本身,你有一个'语法错误:'('意想不到的或类似的错误。它与Oracle无关,它只是如何shell解释器工作,回传的字符串到SQL * Plus。
顺便说一句,我通常使用一个heredoc这种事情,并避免将凭据放在命令行,通过 ps 可见;例如:
sqlplus -s / nolog<<!EOF connect username / password @ databasename 执行some_procedure(123,234) exit !EOF pre>I know how to execute stored procedure by single command line
echo execute some_procedure | sqlplus username/password@databasenameBut I am stuck how to pass IN parameter in procedure, actually My procedure taking two parameters. I tried this but not working
echo execute some_procedure(123,234) | sqlplus username/password@databasenameIt will be great if someone can help me on the same.
解决方案With what you've shown, you either need to escape the parentheses:
echo execute some_procedure\(123,234\) | sqlplus username/password@databasenameOr enclose your command in double-quotes:
echo "execute some_procedure(123,234)" | sqlplus username/password@databasenameEither will stop the shell trying to intepret the parathenses itself, which would give you an 'syntax error: '(' unexpected or similar error. It's nothing to do with Oracle really, it's just how the shell interpreter works, before it gets as far as piping the echoed string to SQL*Plus.
Incidentally, I'd generally use a heredoc for this sort of thing, and avoid putting the credentials on the command line so they aren't visible via ps; for example:
sqlplus -s /nolog <<!EOF connect username/password@databasename execute some_procedure(123,234) exit !EOF
更多推荐
如何在单个命令行中调用存储过程中传递输入参数
发布评论