emacs sql-mode in Win2k works! 
Author Message
 emacs sql-mode in Win2k works!

Folks,

This message is for those out there who might be interested in getting
emacs sql-mode working with DB2. This is how I solved the problem in
Windows2000; YMMV on other systems. I am putting this (a couple of
hours worth of research) out there because I couldn't find out how to
do this anywhere on the web.

The core strategy is to get the DB2 command line tool (DB2.exe) working
in emacs. Unfortunately this is not as straightforward as you may think.
Running db2.exe standalone produces the following error message.
  "DB21061E  Command line environment not initialized." .

My workaround is (a bit manual) to run
  db2cmd /i set db2clp
which produces output like this:
  => DB2CLP=183888277

It turns out that once you set this in your environment in Windows,
db2.exe runs fine.  The big number is a timestamp of sorts, and for
various arcane reasons, is needed in the env. before db2.exe will run.

Here is the emacs code that you need to execute:
  (setq sql-db2-program "c:/sqllib/bin/db2.exe") ; adjust to your actual path
  (setenv "DB2CLP" "183888277") ; use # from output earlier
  (setq sql-db2-options '("-t")) ; "-t" means use ';' as the terminating character.
  ;(setq sql-user "XXX") ; use with care
  ;(setq sql-password "xxx") ; use with care

Now, running M-x sql-db2 should give you an interactive session with DB2.
Load a SQL buffer, set sql-mode and you should be able to use the very handy
C-c C-b and C-c C-r commands to execute all or a region of your SQL. It will feel
magical compared to cut and paste into the IBM supplied GUI windows. Note the use
of the "-t" option above - very handy! If anyone knows of a simpler way, I would
love to hear of it.

Enjoy,
Roy.



Tue, 14 Sep 2004 06:24:15 GMT
 emacs sql-mode in Win2k works!

Roy-
I'll include your code as GPL into EMacro, http://emacro.sf.net/
but not into the upcoming production release.
Your procedure looks like it should apply to DB2 on various OSes, not
just w2k, but also w9x, nt, linux, etc. Have you tried any other OS?
...
 > My workaround is (a bit manual) to run
 >   db2cmd /i set db2clp
 > which produces output like this:
 >   => DB2CLP=183888277
The above just needs a little elisp written, to cache the result
(GPL code donations welcome :)

 > Here is the emacs code that you need to execute:
 >   (setq sql-db2-program "c:/sqllib/bin/db2.exe") ; adjust to your
actual path
 >   (setenv "DB2CLP" "183888277") ; use # from output earlier
 >   (setq sql-db2-options '("-t")) ; "-t" means use ';' as the
terminating character.
 >   ;(setq sql-user "XXX") ; use with care
 >   ;(setq sql-password "xxx") ; use with care
 >
 > Now, running M-x sql-db2 should give you an interactive session
with DB2.
...



Wed, 15 Sep 2004 00:16:00 GMT
 emacs sql-mode in Win2k works!


Quote:
> Roy-
> I'll include your code as GPL into EMacro, http://emacro.sf.net/
> but not into the upcoming production release.
> Your procedure looks like it should apply to DB2 on various OSes, not
> just w2k, but also w9x, nt, linux, etc. Have you tried any other OS?
> ...

It is possible to do this more easily without any "manual steps."  Just
add the following to your .emacs:

    (setq sql-db2-program "db2cmd")
    (setq sql-db2-options '("-c" "-i" "-w" "db2" "-tv"))

The "-tv" option above is not *necessary* (in fact the default behavior
defined in sql.el does not provide this) but I like it because this
allows multi-line input commands (with ';' as the statement terminator)
and makes C-c C-c (sql-send-paragraph) a LOT easier to use.  It also
echos the SQL commands executed in the *SQL* buffer.

This applies to Windows platforms only.  SQL-mode (sql-db2) works by
default on UNIX platforms for DB2.

I have also made a few changes to sql.el that allow it to automatically
work with DB2 regardless of platform.  I am submitting them to the the
sql.el maintainer for inclusion into future releases of sql.el.

Thanks,

Ian

-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----



Wed, 15 Sep 2004 23:16:26 GMT
 emacs sql-mode in Win2k works!
So far so good. It seems though as if the CLP ships ^M (and they get
displayed in the SQL buffer).
Any clue how to purge those?

Cheers
Serge
--
Serge Rielau
DB2 UDB SQL Compiler Development
IBM Software Lab, Canada



Fri, 17 Sep 2004 08:11:59 GMT
 emacs sql-mode in Win2k works!
Solved:
http://www.emacswiki.org/cgi-bin/wiki.pl?ShellMode

(add-hook 'comint-output-filter-functions
            'comint-strip-ctrl-m)

Cheers
Serge
--
Serge Rielau
DB2 UDB SQL Compiler Development
IBM Software Lab, Canada



Fri, 17 Sep 2004 08:27:48 GMT
 
 [ 5 post ] 

 Relevant Pages 

1. SQL emacs-mode for Sybase SQL?

2. Emacs SQL mode?

3. pl-sql mode for emacs

4. Emacs/XEmacs mode for inferior SQL*Plus

5. New version of PL/SQL mode for Emacs?

6. gnu emacs mode for editing SQL?

7. Any emacs mode for SQL/TSQL ?

8. emacs sql mode anyone

9. SQL mode for Emacs?

10. SUMMARY: Emacs SQL mode

11. EMACS SQL-MODE

12. SQL mode for emacs-19.25


 
Powered by phpBB® Forum Software