Is there a GET command?

Moderator: NorbertKrupa

Post Reply
User avatar
Josh
Intermediate
Intermediate
Posts: 106
Joined: Thu Jan 26, 2012 9:38 pm

Is there a GET command?

Post by Josh » Wed Jan 28, 2015 1:58 pm

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?
Thank you!
Joshua

User avatar
JimKnicely
Site Admin
Site Admin
Posts: 1811
Joined: Sat Jan 21, 2012 4:58 am
Contact:

Re: Is there a GET command?

Post by JimKnicely » Wed Jan 28, 2015 2:56 pm

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;
Jim Knicely

Image

Note: I work for Vertica. My views, opinions, and thoughts expressed here do not represent those of my employer.

NorbertKrupa
GURU
GURU
Posts: 527
Joined: Tue Oct 22, 2013 9:36 pm
Location: Chicago, IL
Contact:

Re: Is there a GET command?

Post by NorbertKrupa » Wed Jan 28, 2015 4:16 pm

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=>
Checkout vertica.tips for more Vertica resources.

User avatar
JimKnicely
Site Admin
Site Admin
Posts: 1811
Joined: Sat Jan 21, 2012 4:58 am
Contact:

Re: Is there a GET command?

Post by JimKnicely » Wed Jan 28, 2015 4:20 pm

Yeah! That's brilliant, norbertk! And it works!

Code: Select all

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

dbadmin=> \p
select * from dual
Jim Knicely

Image

Note: I work for Vertica. My views, opinions, and thoughts expressed here do not represent those of my employer.

User avatar
Josh
Intermediate
Intermediate
Posts: 106
Joined: Thu Jan 26, 2012 9:38 pm

Re: Is there a GET command?

Post by Josh » Wed Jan 28, 2015 4:24 pm

Thanks for the help guys. This is what I needed :) :) :)
Thank you!
Joshua

Post Reply

Return to “vSQL”