API Reference

ODPI-C Naming Conventions

All enums, constants and structs in ODPI-C library use the prefix DPI or dpi.

In Oracle.jl, the Julia implementation of these elements use the prefix ORA or Ora.

Examples:

  • The ODPI-C constant DPI_MODE_AUTH_SYSDBA becomes ORA_MODE_AUTH_SYSDBA in Julia.

  • The ODPI-C enum dpiAuthMode becomes OraAuthMode in Julia.

  • The ODPI-C struct dpiTimestamp becomes OraTimestamp in Julia.

All julia structs with prefix Ora are raw wrappers around ODPC-C structs and may contain unsafe attributes.

Safe equivalent Julia structs drop the Ora prefix.

ODPI-C function wrappers have their name preserved, as in dpiContext_create.

Connection

Oracle.ConnectionType
Connection(user::AbstractString, password::AbstractString, connect_string::AbstractString;
        encoding::AbstractString=DEFAULT_CONNECTION_ENCODING,
        nencoding::AbstractString=DEFAULT_CONNECTION_NENCODING,
        create_mode::Union{Nothing, OraCreateMode}=nothing,
        edition::Union{Nothing, String}=nothing,
        driver_name::Union{Nothing, String}=nothing,
        auth_mode::OraAuthMode=ORA_MODE_AUTH_DEFAULT,
        pool::Union{Nothing, Pool}=nothing
    )

Creates a connection to the Oracle Database.

Connections should always be closed after use by calling Oracle.close.

Example

import Oracle

username = "my_username"
password = "my_password"
connect_string = "//IP_ADDRESS/XE" # a valid Oracle connect string

conn = Oracle.Connection(username, password, connect_string)

# connections should always be closed after use.
Oracle.close(conn)
source
Oracle.pingFunction
ping(conn::Connection)

Pings the database server to check if the connection is still alive. Throws error if can't ping the server.

source
Oracle.commitFunction
commit(conn::Connection)

Commits the current active transaction.

source
Oracle.set_client_identifierFunction
set_client_identifier(conn::Connection, client_identifier::AbstractString)

Sets the CLIENT_IDENTIFIER attribute on the connection. This is useful for audit trails and database triggers.

The following query can be used to retrieve this attribute.

SELECT SYS_CONTEXT('USERENV', 'CLIENT_IDENTIFIER') CTX_CLIENT_IDENTIFIER FROM DUAL
source
Oracle.set_client_infoFunction
set_client_info(conn::Connection, client_info::AbstractString)

Sets the CLIENT_INFO attribute on the connection. This is useful for audit trails and database triggers.

The following query can be used to retrieve this attribute.

SELECT SYS_CONTEXT('USERENV', 'CLIENT_INFO') CTX_CLIENT_INFO FROM DUAL
source

Statement

Oracle.executeFunction
execute(stmt::Stmt; exec_mode::dpiExecMode=ORA_MODE_EXEC_DEFAULT) :: UInt32

Returns the number of columns which are being queried. If the statement does not refer to a query, the value is set to 0.

source
execute(connection::Connection, sql::AbstractString;
    scrollable::Bool=false,
    tag::AbstractString="",
    exec_mode::OraExecMode=ORA_MODE_EXEC_DEFAULT
) :: UInt32

Execute a single sql statement.

Returns the number of columns which are being queried. If the statement does not refer to a query, the value is set to 0.

source
Oracle.fetch_array_size!Function
fetch_array_size!(stmt::Stmt, new_size::Integer)

Sets the array size used for performing fetches. All variables defined for fetching must have this many (or more) elements allocated for them. The higher this value is the less network round trips are required to fetch rows from the database but more memory is also required.

A value of zero will reset the array size to the default value of DPIDEFAULTFETCHARRAYSIZE.

source
Oracle.fetchFunction
fetch(stmt::Stmt) :: FetchResult

Fetches a single row from the statement.

source

Variable

Oracle.get_returned_dataFunction
get_returned_data(variable::Variable, pos::Integer) :: Vector

Collects all the data bounded to variable at position pos being transfered to and from the database.

source
Oracle.defineFunction
define(stmt::QueryStmt, column_position::Integer, variable::Variable)

Defines the variable that will be used to fetch rows from the statement. stmt must be an executed statement.

A Variable v bound to a statement stmt must satisfy:

v.buffer_capacity >= fetch_array_size(stmt)

source

Lob

Oracle.chunk_sizeFunction
chunk_size(lob::Lob) :: UInt32

Returns the chunk size, in bytes, of the internal LOB. Reading and writing to the LOB in multiples of this size will improve performance.

source

Misc