Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
Database Servers
DB2InformixIngresMS SQLOraclePervasive.SQLPostgreSQLProgressSybase
Desktop Databases
FileMakerFoxProMS AccessParadox
General
General DB TopicsDatabase Theory
Related Topics
Java Development.NET DevelopmentVB DevelopmentMore Topics ...

Database Forum / DB2 Topics / December 2007

Tip: Looking for answers? Try searching our database.

Problems with DB2 under Debian

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
SpecialTux86 - 09 Dec 2007 12:54 GMT
Greetings.

I have some problems with DB2 under Linux.

I'm running IBM DB2 V9.5 on a Debian Testing system. My configuration is as
follows:

--every DB2 component installed on my PC, except the Informix-related
functions

--DAS user, instance user ("mydbinst") and fenced user are created by the
setup program
--instance auto-starting, created by the setup program
--toolsdb database created by the setup program for "mydbinst"

--"my_account" normal user, which I have added to all the 3 DB2 user groups
(DAS, instance and fenced)

I am the only user in the system (client and server on the same PC), and I
have not altered the configuration written by the setup program.

I have the following problems with DB2, in order of importance:

1)If I start, as "my_account" user, the db2cc (Control Center) from the /bin
subdirectory of the db2 installation directory, it runs. However, if I try
to see the tables of the "TOOLSDB" data, or simply to create a new
database, I get:

"[IBM][CLI Driver] SQL1032N  No start database manager command was issued.
SQLSTATE=57019 ....."

Now, if I log to Gnome as mydbinst, and choose "START" after right-clicking
the instance in the db2cc, the error happens no more until system restarts;
however, if I am logged in as "my_account" user, WHICH BELONGS TO EVERY DB2
GROUP, when choosing "START" on the instance I get an error:

"The admin node "LOCALHOS" does not exist in the DB2 node directory. ....
Verify that the node name "<node-name> is cataloged in the admin node
directory using the LIST ADMIN NODE DIRECTORY command."

Now, if I execute, as "my_account", the suggested command (from the command
editor, or from the db2 command line), I can see that the node EXISTS in
the catalog!!!

The same error occurs other times, for example if I try to right-click
the "LOCALHOST" node and choose "About" when I am logged as "my_account".

No error happens when I am logged as "mydbinst": I can start and stop the
instance, and see the "About" information for the node, ...

Why these errors happen when I am logged as the "my_account" user? How could
I make the db2cc work correctly under "my_account"?

2)Even if I have the "readline" library, the "db2" interactive mode does not
support command history: if I press the "up" arrow button, a strange char
sequence is shown, NOT the previous command!!!
How could I get the correct behaviour?

Thanks in advance.
Colin Booth - 09 Dec 2007 16:21 GMT
> Greetings.
>
[quoted text clipped - 56 lines]
>
> Thanks in advance.

The db2 instance must be started before you can do things like connect to
databases (db2start or right click on the instance in the GUI) See the
documentation for how to autostart the db2 instances

to get other accounts to access the instance you need to run the db2profile
from the SQLLIB directory of the instance to be used
e.g. . /fullpathtotheinstancehomedirectory/sqllib/db2profile

remember to put the dot and space before the fully qualified path

db2 has a history command and other commands that can be used to recall edit
and execute previous commands

You need to read the books there is everything that you need to know in the
information center

Colin
SpecialTux86 - 09 Dec 2007 18:26 GMT
> The db2 instance must be started before you can do things like connect to
> databases (db2start or right click on the instance in the GUI) See the
[quoted text clipped - 5 lines]
>
> remember to put the dot and space before the fully qualified path

First of all, thanks A LOT. The first problem is OK, and must be solved as
you told me.
I had tried a lot (about 1 day), and wasn't able to find this small advice
in the HUGE DB2 documentation system.

> db2 has a history command and other commands that can be used to recall
> edit and execute previous commands

Well, I have discovered the HISTORY command, but I'd like to recall previous
commands using arrows, as I do with db2 under Windows, or psql/bash/<any
other shell-based program under Linux>.
In addition, I can't even move the cursor on the current line using the left
and right arrows, because strange characters are shown whenever I press any
arrow key!!! It happens on the Gnome terminal, on the Konsole, and even
under a plain (non X-based) shell.

With PostgreSQL, this happens when I don't compile the command-line executor
with the "readline" library, but in this case, I don't know why this
happens...

Please, could you help me with this problem, too?

> Colin

Bye, St86
Lennart - 09 Dec 2007 18:44 GMT
[...]

> With PostgreSQL, this happens when I don't compile the command-line executor
> with the "readline" library, but in this case, I don't know why this
> happens...
>
> Please, could you help me with this problem, too?

The best way IMO, is to run queries from your normal shell. I.e.:

[lelle@53dbd181 ~]$ db2 connect to sample

  Database Connection Information

Database server        = DB2/LINUX 9.1.2
SQL authorization ID   = LELLE
Local database alias   = SAMPLE

[lelle@53dbd181 ~]$ db2 "select * from emp" | tee myoutputfile.txt

EMPNO  FIRSTNME     MIDINIT LASTNAME        WORKDEPT PHONENO
HIREDATE   JOB      EDLEVEL SEX BIRTHDATE  SALARY      BONUS
COMM
------ ------------ ------- --------------- -------- -------
---------- -------- ------- --- ---------- ----------- -----------
-----------
000010 CHRISTINE    I       HAAS            A00      3978
01/01/1995 PRES          18 F   08/24/1963   152750.00     1000.00
4220.00

[...]
 42 record(s) selected.

[lelle@53dbd181 ~]$ for t in `db2 -x "select tabname from
syscat.tables where tabname like 'A%'"`; do echo $t; done
ACT
ADEFUSR
ATTRIBUTES
ADMINTABINFO
APPL_PERFORMANCE
APPLICATIONS
AUTHORIZATIONIDS

etc. This way you can continue using all your favorite sh stuff.

HTH
/Lennart
SpecialTux86 - 09 Dec 2007 19:57 GMT
> [...]
>>
[quoted text clipped - 5 lines]
>
> The best way IMO, is to run queries from your normal shell. I.e.:

> [lelle@53dbd181 ~]$ db2 connect to sample
>
[quoted text clipped - 30 lines]
>
> etc. This way you can continue using all your favorite sh stuff.

This is a good idea. And the last script - looping over the table names
returned by the db2 command - is really great. Thank you!

Anyway, it's strange that the db2 interpreter is missing this feature just
on Linux... just to know, does this occurs on your Linux, too?

Thank you.

> HTH
> /Lennart

Bye, St86
Will Honea - 09 Dec 2007 23:34 GMT
>> [...]
>>>
[quoted text clipped - 46 lines]
> Anyway, it's strange that the db2 interpreter is missing this feature just
> on Linux... just to know, does this occurs on your Linux, too?

Definitely the same behavior with openSUSE - never occurred to me to use the
above trick.  I have been using an emacs command shell to get the edit
features but this will simplify things.

Signature

Will Honea

--
Posted via a free Usenet account from http://www.teranews.com

Dave Hughes - 10 Dec 2007 07:51 GMT
>>> [...]
>>>>
[quoted text clipped - 6 lines]
>>>
>>> The best way IMO, is to run queries from your normal shell. I.e.:

[snip example]

>>> etc. This way you can continue using all your favorite sh stuff.
>>
[quoted text clipped - 9 lines]
> above trick.  I have been using an emacs command shell to get the edit
> features but this will simplify things.

Yup, this is normal. The CLP isn't linked with readline and doesn't have  
any inline editing facilities. However, this isn't such a big deal once  
you get used to the idea that the CLP keeps connections open between  
invocations (by means of a background process called db2bp), and therefore  
that you can work with it within another environment (like bash, ksh,  
tcsh, emacs, etc.) taking advantage of that environment's inline editing  
capabilties and (as demonstrated in Lennart's reply) flow control or  
conditionals.

Couple of things to watch out for when working with the CLP under bash  
(the first especially applies to anyone who's familiar with the CLP under  
Window's CMD):

1) Keep in mind the shell's wildcard expansion:

  $ db2 SELECT * FROM MYTABLE

will wind up becoming:

  $ db2 SELECT [all files in the directory] FROM MYTABLE

which is almost certainly not what you want :-)

2) Be careful about redirection characters:

  $ db2 SELECT COLA FROM MYTABLE WHERE COLA > COLB
  $ db2 SELECT COLA || COLB FROM MYTABLE

will both fail, in the first case creating a "COLB" file.

The solution is simply to quote stuff that includes wildcards or  
redirection characters (or just get in the habit of quoting every  
statement):

  $ db2 "SELECT * FROM MYTABLE"
  $ db2 "SELECT COLA FROM MYTABLE WHERE COLA > COLB"
  $ db2 "SELECT COLA || COLB FROM MYTABLE"

Cheers,

Dave.
Colin Booth - 10 Dec 2007 12:14 GMT
>>>> [...]
>>>>>
[quoted text clipped - 64 lines]
>
> Dave.

The best way to put commands in and view the output is with the GUI DB2
Command Editor

Colin
Dave Hughes - 10 Dec 2007 14:22 GMT
[snip
>> Yup, this is normal. The CLP isn't linked with readline and doesn't have
>> any inline editing facilities. However, this isn't such a big deal once
[quoted text clipped - 5 lines]
>> capabilties and (as demonstrated in Lennart's reply) flow control or
>> conditionals.
[snip]

> The best way to put commands in and view the output is with the GUI DB2
> Command Editor

Urgh ... I'll take a Linux bash session with all its handy tools (less,  
awk, sed, grep, tee, et al.) plus a decent editor (vim in my case) over  
that thing anyday ;). Still, each to their own. I'm sure it's fine for  
many people, I'm just more of a command line addict.

Cheers,

Dave.
Lennart - 10 Dec 2007 14:49 GMT
[...]
> Urgh ... I'll take a Linux bash session with all its handy tools (less,
> awk, sed, grep, tee, et al.) plus a decent editor (vim in my case) over
> that thing anyday ;). Still, each to their own. I'm sure it's fine for
> many people, I'm just more of a command line addict.

At least there is two of us then :-) Just wondering, have you tried:

http://www.vim.org/scripts/script.php?script_id=356

I took it for a short spin but didn't have the time to figure it out.
Looks interesting though.

/Lennart
Colin Booth - 10 Dec 2007 20:34 GMT
> [...]
>> Urgh ... I'll take a Linux bash session with all its handy tools (less,
[quoted text clipped - 10 lines]
>
> /Lennart

The db2 CLP arrow recall and proper command line editing do work but under
windows. If you wish to work in this mode you can always use a windows
client. It tends to be faster than using a unix or linux client clp.

If I use the GUI I can at least read the output and save it as HTML

Colin
Lennart - 11 Dec 2007 05:15 GMT
[...]

> If I use the GUI I can at least read the output

If it is linebreaking that bothers you, you can either resize your
xterm or pipe the output through less -S as in:

db2 "select .... from T ...." | less -S

/Lennart
Dave Hughes - 11 Dec 2007 12:13 GMT
>> [...]
>>> Urgh ... I'll take a Linux bash session with all its handy tools (less,
[quoted text clipped - 14 lines]
> under
> windows.

That's because it's not the CLP implementing the recall and command line  
editing - the Windows CMD environment implements all that on behalf of any  
command line application. Unfortunately this means that the editing  
capabilities of any command line application under Windows are subject to  
the (very annoying) limitations of the CMD (e.g. I can't search the  
history, the history doesn't persist across sessions, the editing  
facilities are incredibly basic, etc. etc.)

> If you wish to work in this mode you can always use a windows
> client. It tends to be faster than using a unix or linux client clp.

rofl

Cheers,

Dave.
Serge Rielau - 11 Dec 2007 14:23 GMT
Some history capabilities were built into the CLP eons ago (DB2
V7.2/V8.1..??)
http://publib.boulder.ibm.com/infocenter/db2luw/v9r5/topic/com.ibm.db2.luw.admin
.cmd.doc/doc/r0010839.html


You can also invoke an editor from the CLP.
Signature

Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

Dave Hughes - 11 Dec 2007 11:46 GMT
> [...]
>> Urgh ... I'll take a Linux bash session with all its handy tools (less,
[quoted text clipped - 8 lines]
> I took it for a short spin but didn't have the time to figure it out.
> Looks interesting though.

It certainly does look interesting. I've tried it out but it looks  
(bizarrely) like the DB2 support was really designed for use under Windows  
(there's something slightly disturbed about running vim under Windows :-).  
Under Windows it'll use "db2cmd -i -w -c db2" to execute stuff, and I  
suspect it'd work fine (although I haven't tried it).

Under Linux/UNIX it tries to use db2batch to execute SQL (instead of just  
db2). Unfortunately it does so with a command line like:

  db2batch -q off -s off -a username/password -l ; -f /tmp/somescript.sql

Which fails due to the unquoted semi-colon (bash winds up trying to run  
two commands, an incomplete db2batch command, and an unknown "-f" command  
:-). So, I tweaked the script to quote the -l option, then discovered  
db2batch wants the database specified on the command line, not in the  
script, so set the dbname variable, then discovered db2batch is trying  
"unsupported options on the database node", then tried setting  
"use_db2batch" to "0" (which is the default on Windows), but it tries to  
use "db2cmd" which of course doesn't exist on Linux.

Anyway, long story short: I've yet to get it working. With a bit more work  
I'm sure I could but I haven't got the time at the mo.

Cheers,

Dave.
Ian - 11 Dec 2007 03:54 GMT
> Definitely the same behavior with openSUSE - never occurred to me to use the
> above trick.  I have been using an emacs command shell to get the edit
> features but this will simplify things.

Will,

If you're using emacs, you should check out sql-db2 mode -- very handy.
Will Honea - 11 Dec 2007 06:36 GMT
>> Definitely the same behavior with openSUSE - never occurred to me to use
>> the
[quoted text clipped - 4 lines]
>
> If you're using emacs, you should check out sql-db2 mode -- very handy.

Thanks for that.  Moving to a new platform is full of hidden goodies just
waiting to be discovered.

Signature

Will Honea

--
Posted via a free Usenet account from http://www.teranews.com

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.