简体   繁体   English

如何从SQL storedprocedure调用shell应用程序?

[英]How do i call a shell app from SQL storedprocedure?

Im trying to call a notepad or calculator from a stored procedure. 我试图从存储过程中调用记事本或计算器。 can anyone help? 有人可以帮忙吗?

For what database will this be? 这将是什么数据库?

For MySql you can write a UDF (User Defined Function - See http://dev.mysql.com/doc/refman/5.0/en/adding-udf.html ) to to this or use the ready made one from the UDF repository guys. 对于MySql,您可以编写UDF(用户定义函数 - 请参阅http://dev.mysql.com/doc/refman/5.0/en/adding-udf.html )或使用UDF存储库中现成的UDF家伙。 See http://www.mysqludf.org/lib_mysqludf_sys/index.php . http://www.mysqludf.org/lib_mysqludf_sys/index.php See the sys_exec function and also the section labelled 'A Note of Caution' ;-) 请参阅sys_exec函数以及标有“A Note of Caution”的部分;-)

For Microsoft SQL see the xp_cmdshell command here: http://msdn.microsoft.com/en-us/library/aa260689%28SQL.80%29.aspx 对于Microsoft SQL,请参阅此处的xp_cmdshell命令: http//msdn.microsoft.com/en-us/library/aa260689%28SQL.80%29.aspx

maybe xp_cmdshell be useful for you. 也许xp_cmdshell对你有用。

Executes a given command string as an operating-system command shell and returns any output as rows of text. 将给定的命令字符串作为操作系统命令shell执行,并将任何输出作为文本行返回。 Grants nonadministrative users permissions to execute xp_cmdshell. 授予非管理用户执行xp_cmdshell的权限。

There are ways to do it in Oracle's PL/SQL as well. 在Oracle的PL / SQL中也有办法实现。 Google: Oracle "External Procedures" or start here: Google:Oracle“外部程序”或从这里开始:

Oracle External Procedures Oracle外部程序

You end up calling to SHELL32.DLL and telling it to open Notepad. 你最终调用SHELL32.DLL并告诉它打开记事本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM