API:EPrints/Database/Oracle

From EPrints Documentation
Revision as of 13:25, 25 February 2010 by Tdb01r (talk | contribs)
Jump to: navigation, search

EPrints 3 Reference: Directory Structure - Metadata Fields - Repository Configuration - XML Config Files - XML Export Format - EPrints data structure - Core API - Data Objects


API: Core API

Latest Source Code (3.4, 3.3) | Revision Log | Before editing this page please read Pod2Wiki


NAME

EPrints::Database::Oracle - custom database methods for Oracle DB

User Comments


SYNOPSIS

These settings are the default settings for the free Oracle developer version:

 # Oracle driver settings for database.pl
 $c->{dbdriver} = "Oracle";
 $c->{dbhost} = "localhost";
 $c->{dbsid} = "XE;
 $c->{dbuser} = "HR";
 $c->{dbpass} = "HR";
 

User Comments


DESCRIPTION

Oracle database wrapper for Oracle DB version 9+.

User Comments


Setting up Oracle

Enable the HR user in Oracle XE.

Set the ORACLE_HOME and ORACLE_SID environment variables. To add these globally edit /etc/profile.d/oracle.sh (for XE edition):

 export ORACLE_HOME="/usr/lib/oracle/xe/app/oracle/product/10.2.0/server"
 export ORACLE_SID="XE"
 

(Will need to relog to take effect)

User Comments


Oracle-specific Annoyances

Use the GQLPlus wrapper from http://gqlplus.sourceforge.net/ instead of sqlplus.

Oracle will uppercase any identifiers that aren't quoted and is case sensitive, hence mixing quoted and unquoted identifiers will lead to problems.

Oracle does not support LIMIT().

Oracle does not support AUTO_INCREMENT (MySQL) nor SERIAL (Postgres).

Oracle won't ORDER BY LOBS.

Oracle requires special means to insert values into CLOB/BLOB.

Oracle doesn't support "AS" when aliasing.

User Comments


METHODS

User Comments


get_server_version

$version = $db->get_server_version

Return the database server version.

User Comments


get_column_type

$real_type = $db->get_column_type( NAME, TYPE, NOT_NULL, [, LENGTH ] )

Returns a column definition for NAME of type TYPE. If NOT_NULL is true the column will be created NOT NULL. For column types that require a length use LENGTH.

TYPE is the SQL type. The types are constants defined by this module, to import them use:

 use EPrints::Database qw( :sql_types );
 

Supported types (n = requires LENGTH argument):

Character data: SQL_VARCHAR(n), SQL_LONGVARCHAR.

Binary data: SQL_VARBINARY(n), SQL_LONGVARBINARY.

Integer data: SQL_TINYINT, SQL_SMALLINT, SQL_INTEGER.

Floating-point data: SQL_REAL, SQL_DOUBLE.

Time data: SQL_DATE, SQL_TIME.

User Comments


get_tables

@tables = $db->get_tables

Return a list of all the tables in the database.

User Comments


has_sequence

$boolean = $db->has_sequence( $name )

Return true if a sequence of the given name exists in the database.

User Comments


has_column

$boolean = $db->has_column( $tablename, $columnname )

Return true if the a table of the given name has a column named $columnname in the database.

User Comments


quote_identifier

$id = $db->quote_identifier( $col [, $col ] )

This method quotes and returns the given database identifier. If more than one name is supplied joins them using the correct database join character (typically '.').

Oracle restricts identifiers to:

  30 chars long
  start with a letter [a-z]
  { [a-z0-9], $, _, # }
  case insensitive
  not a reserved word (unless quoted?)
 

Identifiers longer than 30 chars will be abbreviated to the first 5 chars of the identifier and 25 characters from an MD5 derived from the identifier. This should make name collisions unlikely.

User Comments