{"id":634,"date":"2012-04-17T16:46:18","date_gmt":"2012-04-17T15:46:18","guid":{"rendered":"http:\/\/blog.soton.ac.uk\/oneshare\/?p=634"},"modified":"2012-11-19T12:48:37","modified_gmt":"2012-11-19T11:48:37","slug":"oracle-databases","status":"publish","type":"post","link":"https:\/\/blog.soton.ac.uk\/oneshare\/2012\/04\/17\/oracle-databases\/","title":{"rendered":"Oracle Databases"},"content":{"rendered":"<p>Yesterday, I was given access to the data cache held by iSolutions here. Well, a view on to it. And it doesn&#8217;t have every piece of data we requested (first name, last name, e-mail address, faculty, supervisor, degree title, year of degree and photo), let alone all of the data the University holds (which is our eventual goal).<\/p>\n<p>That aside, I was given the keys to dad&#8217;s car and was about to set off on a wild data-ride when I drove straight into the garage door. I know from experience that iSolutions use Oracle as their database system; what I didn&#8217;t know is how hard this is to access.<\/p>\n<p>At first I thought maybe I should download a client so I can interrogate my view of the database, before installing the necessary PHP extension to access it programmatically. I found out this client (or part of it) is called SQL*Plus and headed over to the <a href=\"http:\/\/www.oracle.com\/technetwork\/topics\/winx64soft-089540.html\">Oracle client download page<\/a>.<\/p>\n<p>However, after agreeing to the license and clicking the download link, I was hit with this page:<\/p>\n<p><a href=\"http:\/\/blog.soton.ac.uk\/oneshare\/files\/2012\/04\/Error.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-635\" src=\"http:\/\/blog.soton.ac.uk\/oneshare\/files\/2012\/04\/Error-300x154.png\" alt=\"\" width=\"300\" height=\"154\" srcset=\"https:\/\/blog.soton.ac.uk\/oneshare\/files\/2012\/04\/Error-300x154.png 300w, https:\/\/blog.soton.ac.uk\/oneshare\/files\/2012\/04\/Error-1024x528.png 1024w, https:\/\/blog.soton.ac.uk\/oneshare\/files\/2012\/04\/Error.png 1237w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>I tried a few different links, I tried going to the registration page, but everything to do with the Oracle sign on process was giving me this error page. &#8220;Well forget this client&#8221;, I thought to myself, &#8220;I&#8217;ll just interact with Oracle through PHP&#8221;.<\/p>\n<p>Easier said than done!<\/p>\n<p>Obviously my early code didn&#8217;t work:<\/p>\n<p><code>$conn = oci_connect('hr', 'welcome', 'localhost\/XE');<\/code><\/p>\n<p>The oracle extension isn&#8217;t installed yet, so PHP doesn&#8217;t know what <tt>oci_connect<\/tt> is. &#8220;I&#8217;ve enabled MySQL before, it can&#8217;t be that much harder to enable Oracle&#8221;, I confidently muttered. I followed a few instructions:<\/p>\n<p><a href=\"http:\/\/www.dueyesterday.net\/node\/30\">Installing Oracle libraries for PHP5 on Ubuntu Server 8.04<\/a><code><\/code><\/p>\n<p><a href=\"http:\/\/justalittlebrain.wordpress.com\/2008\/05\/12\/how-to-install-oracle-xe-in-ubuntu-64-bit\/\">How To Install Oracle XE in Ubuntu 64 Bit<\/a><br \/>\n<code> <\/code><\/p>\n<p>The main problem I encountered is that in all cases, I have to download the Oracle client. Except I can&#8217;t get past that sign-on page! The first tutorial has a solution: add the <a href=\"http:\/\/oss.oracle.com\/debian\">Oracle OSS repository<\/a> to your source list and type\u00a0<tt>sudo apt-get install oracle-xe-client<\/tt>. Seems simple, except the repository only has binaries for the x86 version of the client, which <tt>apt-get<\/tt> refuses to install if you have an 64-bit installation of Ubuntu \ud83d\ude41<\/p>\n<p>The second tutorial explains how to manually install the <em>.deb<\/em> packages after <tt>wget<\/tt>ting them from the repository. It was going well until I ran sudo pecl install oci8, and received the following error:<\/p>\n<p><code>\/usr\/bin\/ld: skipping incompatible \/usr\/lib\/oracle\/xe\/app\/oracle\/product\/10.2.0\/client\/lib\/libclntsh.so when searching for -lclntsh<br \/>\n\/usr\/bin\/ld: cannot find -lclntsh<\/code><\/p>\n<p>I cannot find any information about why this doesn&#8217;t work, but I imagine it is because that <em>clntsh<\/em> library is for version 10.2.0 of the client and maybe oci8 expects something newer?<\/p>\n<p>My only solution is that I need to download the latest client and see if that works. While writing this post, it dawned on me that it&#8217;s a bit strange that the Oracle sign on page was not working, so I tried it in a different browser. It turns out that the Oracle sign on page is incompatible with <a href=\"http:\/\/www.opera.com\/download\/\">Opera<\/a>, which is a shame.<\/p>\n<p>I started following <a href=\"http:\/\/mikesmithers.wordpress.com\/2011\/04\/03\/oracle-instant-client-on-ubuntu-with-added-aliens\/\">&#8220;something&#8221;<\/a> but realised it was just making things more complicated and decided to just follow the instructions on the <a href=\"https:\/\/help.ubuntu.com\/community\/PHPOracle\">Ubuntu PHP Oracle page<\/a>. And it works! Now I can connect PHP to Oracle.<\/p>\n<h2>Lessons Learned<\/h2>\n<ol>\n<li>Just follow the instructions on\u00a0<a href=\"https:\/\/help.ubuntu.com\/community\/PHPOracle\">https:\/\/help.ubuntu.com\/community\/PHPOracle<\/a>.<\/li>\n<li>Don&#8217;t use Opera to download from the oracle site, because their <a href=\"http:\/\/www.oracle.com\/webapps\/redirect\/signon\">single sign on<\/a> page does not work.<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>Yesterday, I was given access to the data cache held by iSolutions here. Well, a view on to it. And it doesn&#8217;t have every piece of data we requested (first name, last name, e-mail address, faculty, supervisor, degree title, year &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"more-link\" href=\"https:\/\/blog.soton.ac.uk\/oneshare\/2012\/04\/17\/oracle-databases\/\"> <span class=\"screen-reader-text\">Oracle Databases<\/span> Read More &raquo;<\/a><\/p>\n","protected":false},"author":82342,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15428],"tags":[15410,15427,15430,15425,369,138],"class_list":["post-634","post","type-post","status-publish","format-standard","hentry","category-student-dashboard","tag-studash","tag-client","tag-oci8","tag-opera","tag-oracle","tag-php"],"_links":{"self":[{"href":"https:\/\/blog.soton.ac.uk\/oneshare\/wp-json\/wp\/v2\/posts\/634","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.soton.ac.uk\/oneshare\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.soton.ac.uk\/oneshare\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.soton.ac.uk\/oneshare\/wp-json\/wp\/v2\/users\/82342"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.soton.ac.uk\/oneshare\/wp-json\/wp\/v2\/comments?post=634"}],"version-history":[{"count":12,"href":"https:\/\/blog.soton.ac.uk\/oneshare\/wp-json\/wp\/v2\/posts\/634\/revisions"}],"predecessor-version":[{"id":962,"href":"https:\/\/blog.soton.ac.uk\/oneshare\/wp-json\/wp\/v2\/posts\/634\/revisions\/962"}],"wp:attachment":[{"href":"https:\/\/blog.soton.ac.uk\/oneshare\/wp-json\/wp\/v2\/media?parent=634"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.soton.ac.uk\/oneshare\/wp-json\/wp\/v2\/categories?post=634"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.soton.ac.uk\/oneshare\/wp-json\/wp\/v2\/tags?post=634"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}