Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

VI in SQLPLUS: still the same mess.

5 views
Skip to first unread message

vigi98

unread,
Jan 23, 2006, 8:54:00 AM1/23/06
to
Hi all,

MAYDAY !

On thousands of web pages, I read that you have to type "define
_editor=vi" under SQLPLUS to have a vi-like cmd line but it did never
work for me.

What am I doing wrong ? (I precise that I already tried with the full
path of vi , ie "define _editor=/usr/bin/vi".

Thanks a lot in advance for your help.

sybr...@yahoo.com

unread,
Jan 23, 2006, 9:00:54 AM1/23/06
to
Not much to work in your post, and as we weren't looking over your
shoulder, we don't know what is going wrong.
So
- Which platform?
- Which version of Oracle?
- What happens? or doesn't happen?
- What error messages?
- Does TERM has a value, and if so, what is it?

Because it definitely does work!! No 'vi -like cmd', but you *are*
actually in vi!!

--
Sybrand Bakker
Senior Oracle DBA

Matthias Hoys

unread,
Jan 23, 2006, 9:03:03 AM1/23/06
to

"vigi98" <vig...@free.fr> wrote in message
news:1138024440....@g49g2000cwa.googlegroups.com...

I don't think you can have a command-line vi inside sql*plus like this.
"define _editor=vi" only sets the editor to use when you type the "EDIT"
command (to change your previous sql*plus command).

Matthias


HansF

unread,
Jan 23, 2006, 10:23:06 AM1/23/06
to
Oh great visionary crystal ball, please help us understand the problem for
this lost soul.

As this innocent life form can not speak for himself to guide us into the
unknown, we beg thee to tell us the answer to these hidden questions:
what are the operating system and database version he is using?

Then and only then might we have a clue to the directions we need to look
to help this one into the light.

In the mean time, let us expend valuable energies, perhaps uselessly,
with an example ...

poppa@fuzzy:~> whereis vi
vi: /bin/vi /usr/bin/vi /usr/share/man/man1/vi.1.gz /usr/share/man/man1p/vi.1p.gz
pop2@fuzzy:~> uname -a
Linux fuzzy 2.6.11.4-21.10-default #1 Tue Nov 29 14:32:49 UTC 2005 i686 i686 i386 GNU/Linux
poppa@fuzzy:~> sqlplus hr/hr

SQL*Plus: Release 10.2.0.1.0 - Beta on Mon Jan 23 08:14:35 2006

Copyright (c) 1982, 2005, Oracle. All rights reserved.


Connected to:
Oracle Database 10g Express Edition Release 10.2.0.1.0 - Beta

SQL> define _editor=/usr/bin/vi

SQL> !ls test.sql
ls: test.sql: No such file or directory

SQL> edit test.sql
[goes into full screen vi mode]

select * from dual;
~
~
~
~
~
-- INSERT -- 1,20 All
ESC
ZZ
SQL> !ls test.sql
test.sql

SQL> @test

DUM
---
X


--
Hans Forbrich
Canada-wide Oracle training and consulting
mailto: Fuzzy.GreyBeard_at_gmail.com
*** Top posting [replies] guarantees I won't respond. ***

Matthias Hoys

unread,
Jan 23, 2006, 11:03:43 AM1/23/06
to
I don't think this is what the OP wants - he wants the vi commands available
from the sql*plus commandline, to be able to scroll back/forward in the list
of executed commands (like with the keyboard arrows in Windows sql*plus).
Vigi98 this is what you want, no ?

Matthias


HansF

unread,
Jan 23, 2006, 11:47:27 AM1/23/06
to

I agree.

It was early when I answered, I was grumpy (still am since coffee's not
kicked in yet), and was deliberately being obtuse, as OP did not provide
the environment. (Which seems to be a growing epidemic - again.)

Of course, to answer the OP's question, there are a number of ways, but
some are OS dependent. Howard has shown a beauty at dizwell.com, but
(iirc) it's for command-line Sqlplus in Windows.

And, of course, there is the little known (and very limited) native editor.
I'm always amused at the reaction ("I didn't know you could do that")
when I correct my sql directly like

pop2@fuzzy:~> sqlplus hr/hr

SQL*Plus: Release 10.2.0.1.0 - Beta on Mon Jan 23 09:26:35 2006

Copyright (c) 1982, 2005, Oracle. All rights reserved.


Connected to:
Oracle Database 10g Express Edition Release 10.2.0.1.0 - Beta

SQL> select usernm
2 from user_objects
3
SQL> i
3 wherte object_name like 'C%'
4
SQL> 1
1* select usernm
SQL> c/nm/name, object_name
1* select username, object_name
SQL> l
1 select username, object_name
2 from user_objects
3* wherte object_name like 'C%'
SQL> c/rt/r
3* where object_name like 'C%'
SQL> l
1 select username, object_name
2 from user_objects
3* where object_name like 'C%'
SQL> c/username
1* select , object_name
SQL> c/,
1* select object_name
SQL> l
1 select object_name
2 from user_objects
3* where object_name like 'C%'
SQL> /

OBJECT_NAME
--------------------------------------------------------------------------------
COUNTRIES
COUNTRY_C_ID_PK

SQL>


Painful, yes. But it has it's uses. <g>

Then there are tips like http://vim.sourceforge.net/tips/tip.php?tip_id=41

And iSQLPlus.

And, of course, Raptor - which pretty much nullifies the question
entirely. I can't wait until it's production.

Arto Viitanen

unread,
Jan 24, 2006, 1:29:26 AM1/24/06
to

I know, question was about vi, but the other half of the world uses
Emacs, right? Emacs has function sql-oracle (actually it has several
similar functions, almost one per database system, like sql-mysql etc.)
which runs sqlplus inside Emacs. So you can edit commands, view previous
results etc. inside Emacs. Quite often, instead of sqlplus, I write
emacs -f sql-oracle onto the shell.

--
Arto Viitanen, CSC Ltd
Espoo, Finland

William Robertson

unread,
Jan 24, 2006, 1:27:55 PM1/24/06
to
vigi98 wrote:
> Hi all,
>
> MAYDAY !
>
> On thousands of web pages, I read that you have to type "define
> _editor=vi" under SQLPLUS to have a vi-like cmd line but it did never
> work for me.
>
> What am I doing wrong ? (I precise that I already tried with the full
> path of vi , ie "define _editor=/usr/bin/vi".

That is not supposed to give you "a vi-like cmd line". It sets the
editor to be invoked when you type "ed [filename]". Does that part
work? Do you have a /usr/bin/vi executable?

William Robertson

unread,
Jan 24, 2006, 1:36:45 PM1/24/06
to
Oops, apologies - I didn't see any other posts before posting.

I was trying out the RSS feed, which displays just the first post e.g:
http://groups.google.com/group/comp.databases.oracle.server/msg/b7789013162be612
which gives a neat illusion that you are looking at an unanswered post.
So I'm blaming that.

steph

unread,
Jan 25, 2006, 9:53:46 AM1/25/06
to
have a look at rlwrap (
http://utopia.knoware.nl/~hlub/uck/software/man.html ).

br,
stephan

vigi98

unread,
Jan 26, 2006, 8:08:28 AM1/26/06
to

Pretty painfull, yes :-) But actually, it's really approaching what I
was looking for. By the way, I reckon I didn't understand at all the
use of "define _editor=vi".
THanks for your answer.

vigi98

unread,
Jan 26, 2006, 8:11:44 AM1/26/06
to
Unfortunately, I don't have emacs on the server, and as it's not mine,
I don't want to install it. But I put your solution in a corner of my
mind for a next time. Seems to be very handfull.
Thanks for it.

vigi98

unread,
Jan 26, 2006, 8:13:58 AM1/26/06
to
Yes, I see now that I had misunderstood the aim of this command. I just
wanted to have a vi-like cmd, not vi itself. But thanks for having
taken time to answer.

vigi98

unread,
Jan 26, 2006, 8:17:31 AM1/26/06
to
To be more precise, I was looking for an equivalent of "ied sqlplus"
(HP) for Solaris. And to be even more precise, we are in Oracle
10.2.0.1.0 RAC on SunOS 5.9.

0 new messages