on 2012 Jul 26 6:49 PM
We have a small standalone non-visual application written in powerbuilder that we would like to startup from a SA11 stored procedure. Once running, the program will carry out its activities and end when complete.
How do we script this in a stored procedure?
Are there any special considerations?
The only way to do this would be to use the xp_cmdshell() system procedure. The first thing that comes to mind is that the procedure will wait for the external application to complete before finishing.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
FWIW you can make it asynchronous (fire-and-forget instead of call-and-return) in Windows by using "start"...
BEGIN DECLARE @rc INTEGER; @rc = CALL xp_cmdshell ( 'start notepad', 'no_output' ); SELECT @rc; END;
For one of the more insane examples, see http://sqlanywhere.blogspot.ca/2012/01/you-cant-do-that-in-sql.html
@Glenn: I see you've discovered the "help start" docs available in a command window 🙂
If memory serves, different versions of DOS/Windows support different flavors of START so don't go crazy with the syntax if you have to deploy to multiple platforms.
Plus, as you can see by examples that work without /D, including http://sqlanywhere.blogspot.ca/2012/01/you-cant-do-that-in-sql.html, START is inconsistent in its requirements. I believe the parser is feeble and sometimes confuses a "command" parameter with the optional "title", hence the empty window.
As a final take-away, questions like "how do I call xp_cmdshell" work well in Google, especially here since xp_cmdshell exists in SQL Server as well. Or, to keep it in the family, you can google this:
how do I call xp_cmdshell site:sybase.com
User | Count |
---|---|
71 | |
11 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.