Call scripts in parallel from sqldeveloper - oracle-sqldeveloper

I need to call 3 of my scripts from SQL Developer.
#"myscript1"
#"myscript2"
#"myscript3"
However, I need to call them in parallel. Is there any alternative to having to open 3 Developer sessions and running them in each?

On Windows create a .bat file that launches SQLcl and runs your script, repeat as needed.
My 'run-sleep.cmd' file -
start c:\sqlcl\22.4\sqlcl\bin\sql hr/oracle #c:\users\jdsmith\desktop\sleep.sql
start c:\sqlcl\22.4\sqlcl\bin\sql hr/oracle #c:\users\jdsmith\desktop\sleep.sql
start c:\sqlcl\22.4\sqlcl\bin\sql hr/oracle #c:\users\jdsmith\desktop\sleep.sql
My 'sleep.sql' file -
set serveroutput on
begin
dbms_lock.sleep(3);
dbms_output.put_line('slept 3 seconds, goodbye');
end;
/
On Linux or OS X, you would create a .sh script and do the equivalent call out to the 'sql' binary (found in your SQL Developer bin directory, or available as a separate download.)
Calling the cmd file from OS Prompt, I get 3 new cmd windows, each running SQLcl, running the script(s), concurrently.
FYI Putting your connection password as clear text in a script file isn't recommended.
Disclaimer: I work for Oracle and am the product manager for SQLcl.

Related

Run a bat file when a specific application is opened in Windows XP

I want to know how can we run a bat file when a specific application is opened?
Eg: I would like to run a bat file whenever mspaint is opened.
I have successfully performed this in Windows 7 and Windows 10 using Task Scheduler. But the task scheduler available in Win Xp is very basic.
You could use another batch file that runs on startup of windows. use while loop with an appropriate sleep to detect when Paint.exe runs.
then you could write more commands to do anything you want. For example, as you said, you could run another batch file...
I found this solution by an investigation of these topics:
Syntax for a single-line Bash infinite while loop
How to check if a process is running via a batch script
Batch program to to check if process exists

PostgreSQL copy 0?

I have written a simple batch script which loops a directory and echoes some details about each file.When I view its results in the CMD terminal or output it to some file, I can view the results as expected.
The problem comes with PostgreSQL: when I try to import its results into a table, executing the following command:
copy schema.table(field) from program 'C:\\...\\my_bat.bat' with CSV header delimiter E'\t';
It imports 0 results, whereas if I run the same command pointing to a similar batch file in another directory, it works as expected.
What's going on? I am using windows.
Update: I have tried running the copy command calling program again on another batch script and this time, only a part of the string output is being imported.
The service user postgres needs sufficient permissions to run the program.
I remember that it was hard to change settings for that account on windows XP, I have not tried on more recent windows - service users are hidden by most GUI tools.

Permanently set DB2CLP environment variable

I have a problem with DB2CLP environment variable, on Windows 7 64, IBM_client64_V97 (to be connected with DB2).
Every time when i try to DB2 in Windows command prompt window, I receive this error:
DB21061E Command line environment not initialized.
and per this document using just this step:
2. at the prompt enter these commands:
db2cmd -i -w db2clpsetcp
echo %DB2CLP%
I fix that error, and "db2" command opens Command Line Processor for DB2 Client.
But it lasts only until windows CMD is open. As soon as I close it and reopen, I have to repeat process.
My question (being absolute novice to DB2) is:
How should I make that change permanent and
How this happened at the first place as I installed and setup everything according to the manual (including adding local user to DB2USERS and DB2ADMINS) groups?
When DB2 client is installed, it should have installed a functional window to the command line processor. Check here:
Start / All Programs / IBM DB2 / DB2copy1/ Command Line Processor
Note that DB2copy1 is the default location for the first db2 instance. The name may be different if user select the non-default name.
Shortcut to the CLP can be copied on the desktop.
Regarding the typing "DB2 ..some command..." in windows command prompt which causes described error explanation is as follows:
That's because the normal DOS (or Windows) prompt doesn't
automatically run the setup script that enables the DB2 commands.
When the setup runs, it puts the DB2 items first in the PATH variable.
That could conflict with other tools that also want to be first on the
search list.
If you've got both the DOS (Windows) and DB2 command line prompts on
your desktop, right click them and select Properties. You'll notice
that the system (DOS) prompt runs cmd.exe.
The DB2 prompt runs DB2CMD.exe from the DB2 libraries. The DB2 script
then runs DB2SETCP.BAT and finally DB2.EXE. (All of the DB2
executables should be in C:\Program Files\IBM\SQLLIB\BIN.)
So there are differences in the two prompts. For you purposes, try
running DB2SETCP.BAT from the normal DOS prompt. That may be
sufficient for your needs.
For my purposes I always have the DOS and DB2 prompts on my desktop
and just select the one that I need.

How to Create Windows service from PERL script on Windows 7 64-bit

Does anybody have an example of how to create a windows service on windows 7 64-bit from PERL script?
On windows XP professional 32-bit, I have created windows service successfully with Win32::Daemon which has call back functions. This doesn't work on 64-bit.
I have seen this http://nssm.cc/usage and created a service using that but it doesn't keep state and it gives errors. If anybody has a proper example perhaps ...
Some idea much appreciated.
I managed to solved this now.
I now have my perl script running as a windows service now on windows 7 64-bit.
Basically win32::Daemon works on win 7 64-bit but the service creation needs to be done manually. I.e. the callback functions and start up is fine.
Here is a example to create perl windows service from scratch.
Create folder c:/myservice
Copy the code example from this link and save it to the directory above. Call it myservice.pl (http://www.roth.net/forums/topic.php?id=106)
Add these two lines after the print hello statement in the script.
$Context->{last_state} = SERVICE_RUNNING;
Win32::Daemon::State( SERVICE_RUNNING );
This is needed to keep the service running. Otherwise it stops.
Open a Dos cmd terminal in admin mode. Create service using following command
% sc create myservice binpath= "c:\strawberry\perl\bin\perl.exe"
It will display following message on success.
[SC] CreateService SUCCESS
Now we need to edit the registry. Open registry editor. (start -> then type regedit)
Find the service under HKEY_LOCAL_MACHINE->SYSTEM->CurrentControlSet->Services->myservice
Click on 'myservice' and edit the imagePath variable to be :
c:\strawberry\perl\bin\perl.exe -I "C:\myservice" "C:\myservice\myservice.pl" --run
Now open the services window and start the service. (start->control panel -> Administrative tools -> services)
In the current directory of the script a log is created and updated every couple of seconds. If using cygwin for windows, you can tail it.
% tail -f *.log
Process will print Hello! periodically ...
Thanks.

DB2 executing a Script in another Script

I am facing a problem in DB2. In my Oracle environment it was very easy for me to include multiple scripts in one master script, which were executed sequentially. e.g.:
Master.sql:
connect ....
#script1.sql
#script2.sql
Now I have to build up same logic in DB2 LUW. Is there a simple way to include multiple scripts in one master script? I would like to have one single db2 call from shell, which executes the master script and within all subscripts.
Regards
Jan
There is notrhing to stop you from creating a single file with multiple sql batches. In the Windows world, it would look like this:
Note: First you initialize the db2 command prompt.
db2cmd -c -w -i %1.bat
With as many of these as you want in the .bat file:
db2 -txf c:\Example\db2html.sql
In Linux, the db2clp is included in the shell once you load the db2profile ('. /home/db2inst1/sqllib/db2profile). In windows, you need to call db2cmd in order to use db2clp.
With a interactive db2clp, you cannot call db2 scripts via #scriptX, however, you can call them from the shell like
db2 -tvf script
However, if you use the CLP*Plus you can do almost everything you do in SQL*Plus. For more information: https://www.ibm.com/developerworks/community/blogs/IMSupport/entry/tech_tip_db2_s_new_clp_plus_utility?lang=en