Question

I am on a unix server which is set up to remotely connect to another db2 unix server. I was able to connect to DB2 using following script:

db2 "connect to <server name> user <user name> using <pass>";

Then I ran following command to save results of SQL to a file

db2 "select * from <tablename>" > /myfile.txt

The script starts execution but never ends.I tried using -x before select too but same result never ends execution.Table is small has only one record.When I forcefully end execution the header of table gets saved in file with following error:

SQL0952N  Processing was cancelled due to an interrupt.  SQLSTATE=57014

Please help I am stuck in a riddle.

Était-ce utile?

La solution

You could monitor the connection and the output file in order to know what is happening.

Before start the monitoring, get the current application handle

db2 "values SYSPROC.MON_GET_APPLICATION_ID()"
  • Open a second terminal, and execute db2top against your databases. Checks the current sessions (L) and take a look at your connection (previous application ID). If you see a Lock Wait status, it is just because another connection put a lock on that table, and it is not possible to read it concurrently.

    db2top -d myDB

Try to execute the same query with another isolation level

db2 "select * from <tablename> WITH UR"

If that is the problem, you should analyze which other processes are running (modifying data) on the database.

  • Open another terminal, and do a

    tail -f /myfile.txt

If you see the file is changing, it is just because the output is too big. Just wait.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top