Unix Technical Forum

Some Basic Questions.

This is a discussion on Some Basic Questions. within the DB2 forums, part of the Database Server Software category; --> Hi Friends, I want to know some basics in DB2.I am new to DB2. Help me out friends. I ...


Go Back   Unix Technical Forum > Database Server Software > DB2

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-27-2008, 02:28 AM
WantedToBeDBA
 
Posts: n/a
Default Some Basic Questions.

Hi Friends,

I want to know some basics in DB2.I am new to DB2. Help me out
friends.
I am working in Windows 2000(Client). Server running on AIX box.
Version :8.1 ESE

1. In oracle we can set a editor using(set_editor=xxx) and by using
ed we can edit the previous command. Is it possible to do like that in
DB2?
2. In oracle we can put / to execute the last executed query. Is
there any equalent command in DB2?
3. we can find replace using c/xxxxx/yyyy in last executed
query(Oracle). Is there any equalent command in DB2?

Thanks & Regards,
WantedToBeDBA
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-27-2008, 02:28 AM
Dave Hughes
 
Posts: n/a
Default Re: Some Basic Questions.

On 2004-12-14, WantedToBeDBA scribbled:

> I am working in Windows 2000(Client). Server running on AIX box.
>Version :8.1 ESE
>
> 1. In oracle we can set a editor using(set_editor=xxx) and by using
>ed we can edit the previous command. Is it possible to do like that in
>DB2?
> 2. In oracle we can put / to execute the last executed query. Is
>there any equalent command in DB2?


This depends on whether you are running the DB2 Command Line Processor
(CLP) in "interactive" mode or "command" mode. This can also depend on
whether you are connecting to the AIX box via ssh/rsh/telnet and
running DB2 CLP under AIX, or whether you are running DB2 CLP under
Windows.

Firstly, let's tackle running DB2 CLP in "interactive" mode. That's
when you've run the "db2" command with no parameters from a command
line, or clicked on "DB2 Command Line Processor" under Windows:

* The "h" or "history" command prints the command history.
* The "r" or "runcmd" command runs a numbered prior command.
* The "e" or "edit" command edits a numbered prior command.

You can see the syntax for these commands by using "? [command]", for
example the "? e" command will show the following:

{EDIT | E} [EDITOR editor] [command-number]

The editor used by the "e" final command (if not specified explicitly
by the EDITOR argument) is determined by the following list (copied
straight from the manual):

1. the editor specified by the DB2_CLP_EDITOR registry variable
2. the editor specified by the VISUAL environment variable
3. the editor specified by the EDITOR environment variable
4. on Windows platforms, the Notepad editor;
on UNIX-based platforms, the vi editor

Furthermore, if you are running DB2 CLP under Windows you should be
able to use the command line editing features of cmd: use the left and
right cursor keys and backspace/delete to edit the current command "in
situ", or the up and down cursor keys to recall entries from the
command history.

If you are running DB2 CLP under AIX or Linux you can't use the cursor
keys in this way (at least, it's never worked for me, I think it's
functionality provided by cmd itself). In this case, you're better off
running the CLP in "command" mode (you can also do this on Windows).
This means that from the shell/cmd prompt you run the "db2" command
with whatever SQL you want to execute. For example, here's a little
session from my Linux box under bash:

dave$ db2 CONNECT TO TEST

Database Connection Information

Database server = DB2/LINUX 8.1.5
SQL authorization ID = DAVE
Local database alias = TEST

dave$ db2 "SELECT COUNT(*) FROM COUNTRIES WITH UR"

1
-----------
240

1 record(s) selected.

dave$ db2 TERMINATE
DB20000I The TERMINATE command completed successfully.
dave$

The advantage of this is that you can use the native command line
editing features of whatever shell you're running from
(ksh/bash/cmd/whatever). For this reason, the e, r, and h commands
don't work in this mode.

The disadvantage, is that you may need to deal with quoting issues (in
the above session I had to quote the SQL which contained an asterisk)
and command line length limitations when running the CLP in this way.

> 3. we can find replace using c/xxxxx/yyyy in last executed
>query(Oracle). Is there any equalent command in DB2?


Not as far as I know, though if you ssh/rsh/telnet to your AIX box and
run the CLP in command mode as described above, you'll probably find
the native command line editing features of your shell (likely ksh on
AIX) provide this capability.

HTH, Dave.
--
Cogito cogito ergo cogito sum
-- Ambrose Bierce
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-27-2008, 02:28 AM
Serge Rielau
 
Posts: n/a
Default Re: Some Basic Questions.

WantedToBeDBA wrote:
> Hi Friends,
>
> I want to know some basics in DB2.I am new to DB2. Help me out
> friends.
> I am working in Windows 2000(Client). Server running on AIX box.
> Version :8.1 ESE
>
> 1. In oracle we can set a editor using(set_editor=xxx) and by using
> ed we can edit the previous command. Is it possible to do like that in
> DB2?
> 2. In oracle we can put / to execute the last executed query. Is
> there any equalent command in DB2?
> 3. we can find replace using c/xxxxx/yyyy in last executed
> query(Oracle). Is there any equalent command in DB2?
>
> Thanks & Regards,
> WantedToBeDBA

Take a look at the EDIT and HISTORY command:
http://publib.boulder.ibm.com/infoce...e/r0010838.htm

I personally run the CLP from a shell within xemacs which gives be full
editor and recall capabilities.

Here's some more info on using emacs with DB2:
http://www-128.ibm.com/developerwork...206mathew.html

Cheers
Serge
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-27-2008, 02:28 AM
Dave Hughes
 
Posts: n/a
Default Re: Some Basic Questions.

On 2004-12-14, Serge Rielau scribbled:

[Snip]
>I personally run the CLP from a shell within xemacs which gives be
>full editor and recall capabilities.
>
>Here's some more info on using emacs with DB2:
>http://www-128.ibm.com/developerwork...ticle/0206math
>ew/0206mathew.html


Nice! You wouldn't happen to know if vim has a similar capability to
emacs comint would you?

Thanks, Dave.
--
Cogito cogito ergo cogito sum
-- Ambrose Bierce
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-27-2008, 02:28 AM
Serge Rielau
 
Posts: n/a
Default Re: Some Basic Questions.

Dave Hughes wrote:
> On 2004-12-14, Serge Rielau scribbled:
>
> [Snip]
>
>>I personally run the CLP from a shell within xemacs which gives be
>>full editor and recall capabilities.
>>
>>Here's some more info on using emacs with DB2:
>>http://www-128.ibm.com/developerwork...ticle/0206math
>>ew/0206mathew.html

>
>
> Nice! You wouldn't happen to know if vim has a similar capability to
> emacs comint would you?
>
> Thanks, Dave.

I cannot imagine that vim-ies will admit that there is a feature lacking ;-)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 02-27-2008, 02:28 AM
Dave Hughes
 
Posts: n/a
Default Re: Some Basic Questions.

On 2004-12-14, Serge Rielau scribbled:

>Dave Hughes wrote:
>> On 2004-12-14, Serge Rielau scribbled:
>>
>> [Snip]
>>
>>>I personally run the CLP from a shell within xemacs which gives be
>>>full editor and recall capabilities.
>>>
>>>Here's some more info on using emacs with DB2:
>>>http://www-128.ibm.com/developerwork...charticle/0206
>>>math ew/0206mathew.html

>>
>>
>> Nice! You wouldn't happen to know if vim has a similar capability
>>to emacs comint would you?
>>
>> Thanks, Dave.

>I cannot imagine that vim-ies will admit that there is a feature
>lacking ;-)


lol!

Having searched around a bit I must sadly admit that my favoured editor
does appear to lack a feature of "the other one" ;-)

(The heavy use of caveats in that prior paragraph was because I
certainly cannot claim to be an absolute authority on vim and wouldn't
want to impugn the name of a fine editor unjustly!)

The ! command in vim (for filtering lines of text through an external
application) is rather useful in this regard, and I've used it in the
past to selectively execute lines of a script, replacing them with the
output of the DB2 CLP. However, this isn't the same functionality as
emacs appears to provide with its natty comint thingy.

(obviously I'm not an authority on emacs either ... I tried to like it
.... really ... I guess it's just genetic :-)

Dave.
--
Cogito cogito ergo cogito sum
-- Ambrose Bierce
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 04:53 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com