Oracle

Functionality is right now identical to that of the MySQL plugin, with no additional Oracle specific functionality. All hard coded queries and functions have only been changed to be OCI8 comaptible. For further details, enhanced functions, behavior and examples, see the MySQL plugin.

Command line interface

Syntax

  1. $ oracle [-u username] [--user=username] [-ppassword] [--password=password] [-h hostname] [--host=hostname]

Arguments

  • username – (string, optional) Username to connect with.
  • password – (string, optional) Password to connect with.
  • hostname – (string, optional) host to connect to, e.g. localhost/XE.

Example

Todo

  • Implement SQLPlus style variables with oci_bind for multiple commands on a single line, like MySQL supports SET @var
  • Rename EXEC and EXECUTE statements to CALL
  • Implement rewrite for DESC or DESCRIBE statements

Connect to Oracle via PHP and Apache

On Oracle Linux make sure that the system are set up to make a connection between PHP and Oracle. For error handling check Apache errorlog.

  1. Install PEAR for PHP
  2. Copy absolute path to ORACLE_HOME to clipboard.
    # su oracle
    $ set | grep ORACLE_HOME
    $ exit
  3. PECL is included in; now run
    pecl install oci8
  4. Paste ORACLE_HOME when prompted
  5. Append extension=oci8.so to /etc/php.ini (check the correct location with phpinfo();
    # php -r "phpinfo();" | grep -ni php\.ini
  6. The file /etc/sysconfig/httpd should contain the following lines (make sure in the following that this actually is your ORACLE_HOME dir)
    ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
    ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1; export ORACLE_HOME
    TNS_ADMIN=$ORACLE_BASE/product/11.2.0/dbhome_1/network/admin; export TNS_ADMIN
    PATH=$ORACLE_HOME/bin:$PATH; export PATH
    LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
    CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH
    
  7. Restart Apache
    # apachectl -k graceful

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>