Home » SQL & PL/SQL » SQL & PL/SQL » Execute Windows Command (Oracle Database, 10g, Windows 7)  () 1 Vote
Execute Windows Command [message #651163] Thu, 12 May 2016 05:17 Go to next message
azamkhan
Messages: 557
Registered: August 2005
Senior Member
Hi guys,

I want to execute a windows command CALC for executing calculator program from SQL prompt. I have tried to execute this from SQL environment but it is giving follwong error:

ORA-06550:
Pls-00201: Identifier 'HOST' must be declared
Re: Execute Windows Command [message #651166 is a reply to message #651163] Thu, 12 May 2016 05:37 Go to previous messageGo to next message
Michel Cadot
Messages: 68641
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Please read OraFAQ Forum Guide and How to use [code] tags and make your code easier to read.
Also always post your Oracle version, with 4 decimals, as solution depends on it.

Which tool do you use?
Copy and paste what you do and get.

Re: Execute Windows Command [message #651167 is a reply to message #651166] Thu, 12 May 2016 05:43 Go to previous messageGo to next message
azamkhan
Messages: 557
Registered: August 2005
Senior Member
I am using Oracle Database 10g. And wanted to issue a window command from a database stored procedure.
Re: Execute Windows Command [message #651168 is a reply to message #651167] Thu, 12 May 2016 05:47 Go to previous messageGo to next message
Michel Cadot
Messages: 68641
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Don't you know what 4 decimals mean?
Don't you know what copy and paste mean?
Don't you understand what "Which tool do you use?" mean?

Re: Execute Windows Command [message #651169 is a reply to message #651168] Thu, 12 May 2016 05:49 Go to previous messageGo to next message
azamkhan
Messages: 557
Registered: August 2005
Senior Member
Dear sir, I am using "SQL Command Line" (SQLPLUS which comes with the Oracle database).
Re: Execute Windows Command [message #651170 is a reply to message #651169] Thu, 12 May 2016 05:53 Go to previous messageGo to next message
Michel Cadot
Messages: 68641
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

OK I understand, you have only one slot in your brain and can only answer the last question as the next one will erase the previous one.
So now, "Don't you know what copy and paste mean?".

Re: Execute Windows Command [message #651171 is a reply to message #651168] Thu, 12 May 2016 05:57 Go to previous messageGo to next message
azamkhan
Messages: 557
Registered: August 2005
Senior Member
Michel Cadot wrote on Thu, 12 May 2016 05:47

Don't you know what 4 decimals mean?


Please explain what is 4 decimals
Re: Execute Windows Command [message #651172 is a reply to message #651171] Thu, 12 May 2016 05:59 Go to previous messageGo to next message
Michel Cadot
Messages: 68641
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Don't you ever see an Oracle version in these last 10 years?
What does the SQL*Plus banner tell you? 10g?

Re: Execute Windows Command [message #651173 is a reply to message #651172] Thu, 12 May 2016 06:05 Go to previous messageGo to next message
azamkhan
Messages: 557
Registered: August 2005
Senior Member
Release 10.2.0.1.0
Re: Execute Windows Command [message #651176 is a reply to message #651167] Thu, 12 May 2016 06:31 Go to previous messageGo to next message
EdStevens
Messages: 1376
Registered: September 2013
Senior Member
azamkhan wrote on Thu, 12 May 2016 05:43
I am using Oracle Database 10g. And wanted to issue a window command from a database stored procedure.


Stored procedures execute entirely within the database. They have no means of communicating with the user.
Why do you want to be able to execute the Windows calculator app from within a stored procedure? What is the larger problem you are trying to solve by doing so?


BTW, oracle 10 is long out of support. Even 11 is breathing its last.

[Updated on: Thu, 12 May 2016 06:32]

Report message to a moderator

Re: Execute Windows Command [message #651177 is a reply to message #651173] Thu, 12 May 2016 06:34 Go to previous messageGo to next message
Bill B
Messages: 1971
Registered: December 2004
Senior Member
when I am in sqlplus and I type

HOST CALC

It opens the calculator and waits until I exit the calculator to continue in sqlplus. show up exactly what your test is doing. Also your site might have the host command disabled. It is fairly easy to do by entering a row into the system.product_user_profile table. For example, the following insert would disable the host command for every user on the database

INSERT INTO system.product_user_profile
(product,userid,attribute,scope,numeric_value,char_value)
VALUES
('SQL*Plus', '%', 'HOST', NULL, NULL, 'DISABLED');

[Updated on: Thu, 12 May 2016 06:35]

Report message to a moderator

Re: Execute Windows Command [message #651178 is a reply to message #651177] Thu, 12 May 2016 06:42 Go to previous messageGo to next message
azamkhan
Messages: 557
Registered: August 2005
Senior Member
Bill B wrote on Thu, 12 May 2016 06:34
when I am in sqlplus and I type

HOST CALC

It opens the calculator and waits until I exit the calculator to continue in sqlplus. show up exactly what your test is doing. Also your site might have the host command disabled. It is fairly easy to do by entering a row into the system.product_user_profile table.


This is done manually. I mean a user has to login then issue following

SQL> Host
c:\> CALC
c:\> exit

I want to issue some OS commands automatically for that a DBMS.Schedule can be used. I want to use HOST command in a stored procedure which will execute automatically by the DBMS.Schedule. But when I use HOST command in a database stored procedure it is showing error.
Re: Execute Windows Command [message #651179 is a reply to message #651178] Thu, 12 May 2016 06:44 Go to previous messageGo to next message
Bill B
Messages: 1971
Registered: December 2004
Senior Member
Impossible. A stored procedure runs on the database server, not on the host machine. HOST is a sqlplus command. a stored procedure is executed by the database engine, not sqlplus. Using dbms_schedule you can run a script in sqlplus but it will still run on the server, not the workstation.

[Updated on: Thu, 12 May 2016 06:50]

Report message to a moderator

Re: Execute Windows Command [message #651181 is a reply to message #651179] Thu, 12 May 2016 06:54 Go to previous messageGo to next message
azamkhan
Messages: 557
Registered: August 2005
Senior Member
Thanks Bill
Re: Execute Windows Command [message #651182 is a reply to message #651181] Thu, 12 May 2016 07:26 Go to previous messageGo to next message
Michel Cadot
Messages: 68641
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

This is a great topic for you.
You learned:
- what is an Oracle version
- you have to give us the name the tool you use
- you have to show us what you do and get.

Now, there are other other things you have to learn like how to correctly format a post.
They are in the links I gave you... if you can read... and memorize more than one thing... otherwise return back to them each time you write one line in a post and read them again.

[Updated on: Thu, 12 May 2016 07:27]

Report message to a moderator

Re: Execute Windows Command [message #651183 is a reply to message #651182] Thu, 12 May 2016 07:30 Go to previous messageGo to next message
azamkhan
Messages: 557
Registered: August 2005
Senior Member
Michel Cadot wrote on Thu, 12 May 2016 07:26

This is a great topic for you.
You learned:
- what is an Oracle version
- you have to give us the name the tool you use
- you have to show us what you do and get.

Now, there are other other things you have to learn like how to correctly format a post.
They are in the links I gave you... if you can read... and memorize more than one thing... otherwise return back to them each time you write one line in a post and read them again.



Mr. Michel Cadot, I am here in this forum to learn and I am not ashamed of learning. I am and will always be a student, who wants to learn more and more. Stop insulting people.
Re: Execute Windows Command [message #651184 is a reply to message #651183] Thu, 12 May 2016 07:34 Go to previous messageGo to next message
Michel Cadot
Messages: 68641
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

After 10 years you have learned the basics of how to post in a forum, you deserve to be reviewed.
So read the links and answer correctly to the questions we post you so we have not to repeat them again and again.

In addition, you did mostly not thank people who help you, this topic is an exception.
Who is then insulting Mister Genius?

Re: Execute Windows Command [message #651185 is a reply to message #651184] Thu, 12 May 2016 07:36 Go to previous messageGo to next message
azamkhan
Messages: 557
Registered: August 2005
Senior Member
I am really sorry to say but because of people like you ORA FAQ will not be a good forum for discussion.
Re: Execute Windows Command [message #651186 is a reply to message #651185] Thu, 12 May 2016 08:22 Go to previous messageGo to next message
Michel Cadot
Messages: 68641
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Sure, it is not a chat room.

Re: Execute Windows Command [message #651206 is a reply to message #651178] Thu, 12 May 2016 13:27 Go to previous messageGo to next message
Barbara Boehmer
Messages: 9088
Registered: November 2002
Location: California, USA
Senior Member
azamkhan wrote on Thu, 12 May 2016 04:42

...I want to issue some OS commands automatically for that a DBMS.Schedule can be used....


Here is an example of executing a Windows bat file containing a Windows operating systems command by using dbms_scheduler.create_job and setting the job_type to EXECUTABLE:

http://www.orafaq.com/forum/mv/msg/180761/552285/#msg_552285


Here is another example of executing external programs from within Oracle by using dbms_scheduler.create_program and setting the program_type to EXECUTABLE:

http://www.databasejournal.com/features/oracle/article.php/3365371/Executing-External-Programs-From-Within-Oracle.htm


Here is a link to the section of the Oracle 10.2 online documentation regarding dbms_scheduler that includes executing operating system files containing operating system commands by using dbms_scheduler.create_job setting the job_type to EXECUTABLE or using dbms_scheduler.create_program setting the program_type to EXECUTABLE:

http://docs.oracle.com/cd/B19306_01/appdev.102/b14258/d_sched.htm#CIHHBGGI

Re: Execute Windows Command [message #651207 is a reply to message #651206] Thu, 12 May 2016 13:42 Go to previous messageGo to next message
azamkhan
Messages: 557
Registered: August 2005
Senior Member
Thankyou Barbara.
Re: Execute Windows Command [message #651208 is a reply to message #651207] Thu, 12 May 2016 14:38 Go to previous messageGo to next message
Bill B
Messages: 1971
Registered: December 2004
Senior Member
Yes, that will work however it still will not work on the client. Unless the database is running on the local workstation, you will not see the calculator startup and if it does, it will be for the system account running the database. Not what you logged onto the database server as.
Re: Execute Windows Command [message #651210 is a reply to message #651208] Thu, 12 May 2016 14:50 Go to previous messageGo to next message
Barbara Boehmer
Messages: 9088
Registered: November 2002
Location: California, USA
Senior Member
It should execute the operating system command on the server. I don't know if CALC was just a simple example of an operating system command for testing or if that is the actual command needed. If CALC is the actual command needed, then it should not make any difference where the calculator comes from. It it is something else, then the bat file containing the commands will need to be on the server and run the commands on the operating system of the server.

On second thought, if it is something that can be run without needing to be seen, no problem. It just dawned on me that you are correct in that, although the calculator may pop up on the server, if your client is not on the server, as mine is, so I can't test it properly, then you may not see it, which obviously constitutes a problem.

[Updated on: Thu, 12 May 2016 14:54]

Report message to a moderator

Re: Execute Windows Command [message #651216 is a reply to message #651210] Thu, 12 May 2016 23:29 Go to previous messageGo to next message
azamkhan
Messages: 557
Registered: August 2005
Senior Member
Barbara Boehmer wrote on Thu, 12 May 2016 14:50
I don't know if CALC was just a simple example of an operating system command for testing


Yes its an example of an operating system command for testing purpose.
Re: Execute Windows Command [message #651220 is a reply to message #651210] Fri, 13 May 2016 02:08 Go to previous messageGo to next message
John Watson
Messages: 8929
Registered: January 2010
Location: Global Village
Senior Member
One could use the Scheduler to launch the job on the client, if one is using release 11.2.x or higher. 11.2 introduces the remote external job facility. You install the Scheduler Agent (off the Client CD) on the remote machine, which would be the client PC, and the Scheduler sends the job to it for execution. I have done this for demonstration purposes, but never at a production site.
Re: Execute Windows Command [message #651236 is a reply to message #651216] Fri, 13 May 2016 06:35 Go to previous message
EdStevens
Messages: 1376
Registered: September 2013
Senior Member
azamkhan wrote on Thu, 12 May 2016 23:29
Barbara Boehmer wrote on Thu, 12 May 2016 14:50
I don't know if CALC was just a simple example of an operating system command for testing


Yes its an example of an operating system command for testing purpose.


OK, but for real purposes, does the command need to be interactive with the use? And does it need to access files that are on the user's PC.

You get far better help if you describe the actual business problem and not some hypothetical technical solution.
Previous Topic: create stored procedure with cursor as an out argument
Next Topic: Analytical grouping of data
Goto Forum:
  


Current Time: Fri Apr 19 06:09:05 CDT 2024