What does **$$** mean when configuring PowerShell Command Line for DB2? - powershell

I found this article that shows how you can set up PowerShell to act as your command line for processing DB2 commands.
In the article, it says that you can use the following command to configure PowerShell to run DB2 commands:
Set-Item -Path env:DB2CLP -Value "**$$**"
In the above command, what does the "**$$**" mean?
Thanks!

It has a function, as distinct from a meaning, and the **??** is meant for the Db2 clp (db2.exe). Even if you are not using PowerShell (i.e. you are using db2cmd.exe or cmd.exe) this environment variable can be useful.
It tells the Db2 CLP to configure the current PowerShell session to be able to communicate with the background process db2bp.exe (the communication is IPC based) . Such communication is necessary because it is that background process db2bp.exe which maintains your connection to the database when you run db2 connect to $your_database, or equivalent cmdlet. The db2.exe manages the db2bp.exe so you don't have to worry about it.
The Db2 CLP knows which db2bp.exe it starts for your Powershell session and uses the environment variable DB2CLP as part of that.
Each individual db2 ... command line (or cmdlet) may quickly complete , and will act on the currently connected database, and you can run many db2 commands one after the other, or run scripts - but all the time, it is the background task db2bp.exe that keeps your Db2 connection alive without needing to be reconnected (as long as the Db2 server does not itself end or kill the connection).
The db2bp.exe process will disappear when you run db2 terminate or end the process. You need to run db2 terminate when reconfiguring the node directory, or database directory, or when switching between different Db2-instances that are running on the same hostname, or optionally after db2 connect reset.

Related

How to cancel or terminate long-running query in DB2 CLP without killing CLP?

Assuming I started execution of an inefficient and long-running query in an IBM DB2 database using the CLP. Maybe there are some terrible joins in there that take a lot of processing time in the database. Maybe I don't have the much needed index yet.
# db2 +c -m
db2 => connect to mydb
db2 => select * from view_with_inefficient_long_running_query
//// CLP waiting for database response
How do I cancel the processing of this statement/query without killing DB2 CLP? I can do so by killing it, that is, by pressing Ctrl-C:
db2 => select * from view_with_inefficient_long_running_query
^C
SQL0952N Processing was cancelled due to an interrupt. SQLSTATE=57014
# db2 +c -m
db2 =>
But is there another more elegant way? Perhaps another Ctrl- shortcut? I already saw this question, but it doesn't talk about what I want.
AFAIK, there is not CTRL- to terminate CLP. Your option is to open another terminal session and use the LIST/FORCE applications, CTRL-Z the CLP to suspend it and use another CLP to LIST/FORCE or use a GUI tool like Data Server Manager to find the application and force it to terminate.
db2 list applications for <database>
get the application handle for the session(s) you want to terminate.
db2 force application ( application-handle )
see LIST APPLICATIONS and FORCE APPLICATION.
Would you rather use a QueryTimeout configuration as in https://www.ibm.com/support/knowledgecenter/SSEPGG_9.7.0/com.ibm.db2.luw.apdv.cli.doc/doc/r0008809.html
This way your command would stop and report SQLSTATE 57013
-913 UNSUCCESSFUL EXECUTION CAUSED BY DEADLOCK OR TIMEOUT.
Rather than use CLP directly, why not go directly from the UNIX prompt?
db2 "select * from view_with_inefficient_long_running_query"
You can hit Ctrl-C to cancel your query. The connection to the database is maintained by the DB2 Backend Process (db2bp), and you get all of the benefits of working in a UNIX shell – superior history, command pipelines, etc.

Howto execute a sql command inside transaction

I am using OrientDb Version 2.0 M2 with PLocal connections.
The javadoc of
OCommandRequest com.tinkerpop.blueprints.impls.orient.OrientBaseGraph.command(OCommandRequest iCommand)
says
"Executes commands against the graph. Commands are executed outside transaction."
Now i am wondering, if it is possible to execute my SQL commands inside a transaction.
With current version it's not possible if you use "remote" connections.

IBM DB2 replication on secondary passive machine

I have two machines. Both have their own disks. One machine runs active DB2 and the secondary machine has DB2 installed but not running (only one license). In case the DB goes down, I need to start the secondary DB2 instance. Databases should come back online, it is not so critical that all latest data has been transferred. The
What is the easiest way to do this? One is to shutdown all databases every night and script a backup routine. Another is HADR, but in this case I'm not sure if HADR requires a spearate license, and if the DB2 instance on the secondary machine must be running (not possible because we only have one license)
You can transfer each archived log each time the file is passed to the archive directory in the primary database.
You transfer that file to the log directory in the second machine.
From time to time, you can perform a "roll forward to end of logs", and that will reduce the time in case of a role switch.
You can also backup the primary and transfer that backup to the other machine. But you have to restore it when switching, and this could be very long.
Probably, you can also install Express-C in the second one (Two DB2s installed), and you roll forward or restore periodically with this edition. In case of switch, you just change the db2 instance or create a symbolic link to the binaries in order to activate the db2 features not included in express-c.

How to check remote Oracle server is up and running

I have my Oracle server installed in a remote machine and I want a script at my local machine which will check whether Oracle server is up and running or not. I know this can be check by creating a connection through sqlplus or JDBC. But in this case oracle client won't be present and I am saving JDBC approach as my last option. So is there any other simpler way to check this, which can be easily implemented in a shell script???
Thanks
Not really. The only way to be certain that the database is responding to queries is to run a query on it, such as the venerable:
select dummy from dual

Program cannot reconnect to Firebird after abnormal termination

What can be done to prevent having to restart a PC after a program (C++Builder) terminated abnormaly without closing the database using firebird 2?
What I am looking for: I would like to be able to just restart the program without any other intervention. (I could have the user call a batch file executing some cleanup or add some lines of code to the program to disconnect everything.)
If your database is firebird 2.1+, there are monitoring tables that show the active connections, and the sysdba can manually delete any left-over connnections.
If you look in your release notes, the syntax details should be there.