Page 1 of 1

Is there a GET command?

Posted: Wed Jan 28, 2015 1:58 pm
by Josh
Good morning,

Is there a command in vsql that acts like the GET command in Oracle SQL*Plus that will just loads a host operating system file into the SQL buffer?

Re: Is there a GET command?

Posted: Wed Jan 28, 2015 2:56 pm
by JimKnicely
Hey Josh,

Hmm. I was hoping the \e meta-command would do the trick.

You can run a command like \e /home/dbadmin/test.sql. This will load the file into the default editor. For me it is vi, so I did a :wq! to save the file, but this will also execute the SQL. Then I tried just a :q! to exit vi, but this will not save the file to the SQL buffer.

Maybe once you load the the file into vi with the /e meta-command you can add a WHERE clause predicate like 1=2 so that even though the query is executed, no results are returned.

Code: Select all

dbadmin=> \e /home/dbadmin/test.sql
dbadmin=> \! cat /home/dbadmin/test.sql
select * from dual;
dbadmin=> \e /home/dbadmin/test.sql
 dummy
-------
(0 rows)

dbadmin=> \p
select * from dual
 where 1=2;

Re: Is there a GET command?

Posted: Wed Jan 28, 2015 4:16 pm
by NorbertKrupa
Not sure if it helps, but in the query buffer, you could omit the ; from the statement, then :wq and cancel from the line.

Code: Select all

dbadmin=> \e
dbadmin->

dbadmin=>

Re: Is there a GET command?

Posted: Wed Jan 28, 2015 4:20 pm
by JimKnicely
Yeah! That's brilliant, norbertk! And it works!

Code: Select all

dbadmin=> \e /home/dbadmin/test.sql
dbadmin->

dbadmin=> \p
select * from dual

Re: Is there a GET command?

Posted: Wed Jan 28, 2015 4:24 pm
by Josh
Thanks for the help guys. This is what I needed :) :) :)