Database Journal
MS SQL Oracle DB2 Access MySQL PostgreSQL Sybase PHP SQL Etc SQL Scripts & Samples Links Database Forum

» Database Journal Home
» Database Articles
» Database Tutorials
MS SQL
Oracle
DB2
MS Access
MySQL
» RESOURCES
Database Tools
SQL Scripts & Samples
Links
» Database Forum
» Sitemap
Free Newsletters:
DatabaseDaily  
News Via RSS Feed


follow us on Twitter
Database Journal |DBA Support |SQLCourse |SQLCourse2
 

Featured Database Articles

DB2

Posted Feb 24, 2004

DB2 Command Line Processor Tips and Tricks - Page 3

By DatabaseJournal.com Staff

Interactive CLP Roundtrip Editing


DB2 UDB Version 8.1.2 adds the capability of "roundtrip editing" to the DB2 CLP interactive mode. This integration allows you to run DB2 UDB commands, edit them (using the operating system's integrated command editor or an editor of your choice), and then run the edited commands. To use this feature, invoke the new DB2 interactive CLP command called EDIT. The syntax of this command is shown below:



The <num> option is used to retrieve the sequence number of the command in the command cache. (See the previous section for more information.) If you do not specify this option, the last executed command is loaded into the editor. If you elect to save your changes when you close the editor, the updates will be reflected in the DB2 UDB interactive CLP prompt, and you can run the command immediately if you wish. If you typed multiple commands in the editor, only the first command is retrieved into the CLP interactive session.


The following four screens illustrate the process of running, editing, and rerunning an edited command using the local operating system's text editor:


There are several ways to specify which editor will be invoked when you use the EDIT command. Running this command launches the appropriate editor based on the following ordered criteria:

1.  If the EDITOR <editor> option is specified in the EDIT command, the editor specified by <editor> will be used.

2.  If the DB2_CLP_EDITOR registry variable is set, the editor specified by this variable will be used.

3.  If the VISUAL environment variable is set, the editor specified by this variable will be used.

4.  If the EDITOR environment variable is set, the editor specified by this variable will be used.

5.  Otherwise, the default Notepad editor on Windows operating systems or the VI editor on UNIX-based systems will be used.

Conclusion

DB2 UDB Version 8.1 with FixPak 1 and DB2 UDB Version 8.1.2 introduced new usability features for the DB2 interactive CLP, including customizable DB2 CLP interactive prompts and a command cache that can be accessed or modified through the new DB2 CLP HISTORY command, the RUNCMD command or the EDIT command.

About the Authors

Paul C. Zikopoulos, BA, MBA, is with IBM Canada Ltd. Paul has written numerous magazine articles and books about DB2. Paul has co-authored the books: DB2 Version 8: The Official Guide, DB2: The Complete Reference, DB2 Fundamentals Certification for Dummies, DB2 for Dummies, and A DBA's Guide to Databases on Linux. Paul is a DB2 Certified Advanced Technical Expert (DRDA and Cluster/EEE) and a DB2 Certified Solutions Expert (Business Intelligence and Database Administration). You can reach him at: paulz_ibm at msn.com.

Roman B. Melnyk, PhD, is with IBM Canada Ltd., specializing in database administration, DB2 utilities, and SQL. Roman has written numerous DB2 books, articles, and other related materials. Roman co-authored DB2 Version 8: The Official Guide, DB2: The Complete Reference, DB2 Fundamentals Certification for Dummies, and DB2 for Dummies. You can reach him at roman_b_melnyk at hotmail.com.



DB2 Archives

Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 



















Thanks for your registration, follow us on our social networks to keep up-to-date