Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

If I make a mistake in SQLPlus while inputting an 'insert into' command, is there a way I can bring this information back up in order to edit it?

share|improve this question
    
You need type In command line: Rollback; –  user16063 Dec 11 '12 at 6:21
    
@user16063 --- and what will that do? Can you elaborate at all? –  jcolebrand Dec 11 '12 at 15:14
    
@user16063 I'm pretty sure this is a misunderstanding, Bambi wants to edit the previous command text not roll back a transaction. –  Jack Douglas Dec 12 '12 at 10:45
add comment

3 Answers

Several ways.

You can set the EDITOR environment variable before running SQL*Plus (Assuming Unix), to allow use of an external text editor (vi, by way of example):

export EDITOR=vi

Then type ed in SQL*Plus to edit the previous query in the vi editor. Of course, you may prefer nano, pico, emacs, vim etc etc.

If you don't wish to set an environment variable, you can add define _editor=vi to your $ORACLE_HOME/sqlplus/admin/glogin.sql file instead.

My favourite way of achieving SQL*Plus edit heaven (in Unix) is by using rlwrap. This adds readline support to SQL*Plus and allows you to easily edit within SQL*Plus itself.

Install rlwrap from your distributions package repository (or download & compile from the website here), then add the following to your shells startup script (.bashrc/.bash_profile or similar):

alias sqlplus="rlwrap -i sqlplus"
share|improve this answer
add comment

Unless something has changed, just type "edit" and press enter and it'll open in Notepad (assuming Windows here) and you can change the query in there.

share|improve this answer
add comment

For all commandline application emacs can be used as an interface. You can open the shell mode and run the command line tool. Emacs will send the command you input to the command line tool and read and the display the output. Because you type your input to emacs you can manipulate your input using the emacs commands. Using this mode emacs can be used with the following oracle tools like*

  • rman
  • lsnrctl
  • adrci
  • dgmgrl

There is a special sql-oracle mode that especially supports sqlplus. I worked with it long time ago. Today I did not find it in the documentation. I searched the web and but I found only the following link. Maybe you can find more when searching the emacs documents. There are other sql modes for emacs. This page contains a reference to the link found by @Jack Douglas too.

A lot of people don't like emacs because they think that it is a complex tool.

share|improve this answer
    
I wonder if the downvotes are from vi fans ;) I found this (apparently "inspired by sqlplus-mode.el") on Google—is it the kind of thing you were talking about? –  Jack Douglas Dec 12 '12 at 10:43
    
I think that this is something similar to the sql-oracle mode. –  miracle173 Dec 12 '12 at 22:14
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.