Oracle Forms - 主机命令 - 返回错误代码
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3729710/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Oracle Forms - Host Command - Return Error Code
提问by Courtney
Within a Oracle Forms trigger I am using the host command to make a directory on the file server. An example of this part of my code is below:
在 Oracle Forms 触发器中,我使用 host 命令在文件服务器上创建一个目录。我的代码这部分的一个例子如下:
HOST ('mkdir'||:GLOBAL.DIRECTORY_PATH||'\FERTILIZER\'||ADDY);
主机 ('mkdir'||:GLOBAL.DIRECTORY_PATH||'\FERTILIZER\'||ADDY);
I need to have the error code returned to me if the directory is not created on the server. Any suggestions of the code I need to add?
如果该目录未在服务器上创建,我需要将错误代码返回给我。我需要添加的代码有什么建议吗?
Thank you.
谢谢你。
回答by Jeffrey Kemp
FORM_SUCCESS
will return FALSE
if the command fails for any reason (unless you're on Windows 95 in which case it will still return TRUE
).
FORM_SUCCESS
FALSE
如果命令因任何原因失败,将返回(除非您使用的是 Windows 95,在这种情况下它仍将返回TRUE
)。
HOST('...');
IF NOT FORM_SUCCESS THEN
MESSAGE('something went wrong');
END IF;
回答by Eddy B
If you are looking for the actual OS level error code, then you are out of luck. The aforementioned answer from Jeffrey Kempis the best you will get.
如果您正在寻找实际的操作系统级别错误代码,那么您就不走运了。Jeffrey Kemp的上述答案 是最好的答案。
If you are having failures, keep in mind that the HOST built-in runs on the machine that actually runs the form (normally the application server). So, your command must be valid for the particular OS of the application server.
如果您遇到故障,请记住内置的 HOST 运行在实际运行表单的机器上(通常是应用程序服务器)。因此,您的命令必须对应用服务器的特定操作系统有效。
Also, and you may have figured this out already, in your example, 'mkdir'||:GLOBAL.DIRECTORY_PATH||'\FERTILIZER\'||ADDY
could result in your command having no space between the command - mkdir
and the string, resulting in a failed command.
此外,您可能已经想到了这一点,在您的示例中,'mkdir'||:GLOBAL.DIRECTORY_PATH||'\FERTILIZER\'||ADDY
可能会导致您的命令在命令 -mkdir
和字符串之间没有空格,从而导致命令失败。
回答by Ben Dinh
You still can get the error message by using this statement HOST(vCommand || ' > error.txt');
您仍然可以通过使用此语句 HOST(vCommand || ' > error.txt'); 获取错误消息;