如何在单个命令行中调用存储过程中传递输入参数

编程入门 行业动态 更新时间:2024-10-27 14:21:42
本文介绍了如何在单个命令行中调用存储过程中传递输入参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我知道如何通过单个命令行执行存储过程

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@databasename

But 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@databasename

It 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@databasename

Or enclose your command in double-quotes:

echo "execute some_procedure(123,234)" | sqlplus username/password@databasename

Either 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

更多推荐

如何在单个命令行中调用存储过程中传递输入参数

本文发布于:2023-11-14 21:37:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1588560.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:命令行   过程中   参数   如何在

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!