[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Querying an Oracle DB from Octave?
From: |
Martin Helm |
Subject: |
Re: Querying an Oracle DB from Octave? |
Date: |
Sun, 24 Jul 2011 11:25:18 +0200 |
User-agent: |
KMail/1.13.7 (Linux/2.6.37.6-0.5-desktop; KDE/4.6.5; x86_64; ; ) |
Am Sonntag, 24. Juli 2011, 06:42:38 schrieb markbn:
> > Before I go into more detail, is using the java package in octave an
> > option
> > for you? If yes you can simply use the jdbc driver for oracle and you do
> > not
> > need any administrative rights to install it (you just need for example
> > the
> > ojdbc14.jar provided by oracle).
>
> Hey Martin, thanks for answering. I cannot use java at all in the
> production server.
>
> You may now provide all the details you know on how to access Oracle DBs
> from Octave :-)
>
So it makes not much sense to provide the details how you handle a database
connection via jdbc and query/retrieve with it since that needs java to be
available.
One very simple way to query a database is to use its command line tools to
execute a query and store the result into a csv file which you can easily read
afterwards with octave.
The oracle tool which provides that feature is sqlplus. If I understand what
you said you are running your scripts on the production server and if that is
the same server where you have oracle installed sqlplus should be already
there (of course I do not know if I understand now correctly your setup).
An example how to do such a query from octave is to run something similar to
the following command with octave's "system" command (the following is one
line):
echo -e "set colsep \n set heading off \n set linesize 3000 \n set pagesize
1000000 \n set echo off \n set feedback off \n set trimspool on \n set newpage
none \n set underline off \n select * from example;" | /usr/oracle/bin/sqlplus
username/password@//192.168.0.1:1521/your_sid.com > outputfile.csv
(This is quick and dirty there may be more sophisticated solutions, but it
should show the underlying idea)
and the result of the query (in this example "select * from example") will end
up in the file output.csv which you can now read with csvread or dlmread.
You can also also run sqlplus with popen2 from octave to establish a two way
connection via pipes and send the commands one by one to it and receive the
output also that way.
Re: Querying an Oracle DB from Octave?, CdeMills, 2011/07/25