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_SYSDBAbecomesORA_MODE_AUTH_SYSDBAin Julia.The ODPI-C enum
dpiAuthModebecomesOraAuthModein Julia.The ODPI-C struct
dpiTimestampbecomesOraTimestampin 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.Connection — Type
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)Oracle.ping — Function
ping(conn::Connection)Pings the database server to check if the connection is still alive. Throws error if can't ping the server.
Oracle.commit — Function
commit(conn::Connection)Commits the current active transaction.
Oracle.rollback — Function
rollback(conn::Connection)Rolls back the current active transaction.
Oracle.set_client_identifier — Function
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 DUALOracle.set_client_info — Function
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 DUALStatement
Oracle.execute — Function
execute(stmt::Stmt; exec_mode::dpiExecMode=ORA_MODE_EXEC_DEFAULT) :: UInt32Returns the number of columns which are being queried. If the statement does not refer to a query, the value is set to 0.
execute(connection::Connection, sql::AbstractString;
scrollable::Bool=false,
tag::AbstractString="",
exec_mode::OraExecMode=ORA_MODE_EXEC_DEFAULT
) :: UInt32Execute 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.
Oracle.row_count — Function
Number of affected rows in a DML statement.
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.
Oracle.fetch — Function
fetch(stmt::Stmt) :: FetchResultFetches a single row from the statement.
Variable
Oracle.get_returned_data — Function
get_returned_data(variable::Variable, pos::Integer) :: VectorCollects all the data bounded to variable at position pos being transfered to and from the database.
Oracle.define — Function
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)
Lob
Oracle.chunk_size — Function
chunk_size(lob::Lob) :: UInt32Returns the chunk size, in bytes, of the internal LOB. Reading and writing to the LOB in multiples of this size will improve performance.
Misc
Oracle.odpi_version — Function
odpi_version() :: VersionNumberReturns the underlying odpi library version.