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
becomesORA_MODE_AUTH_SYSDBA
in Julia.The ODPI-C enum
dpiAuthMode
becomesOraAuthMode
in Julia.The ODPI-C struct
dpiTimestamp
becomesOraTimestamp
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.Connection
— TypeConnection(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
— Functionping(conn::Connection)
Pings the database server to check if the connection is still alive. Throws error if can't ping the server.
Oracle.commit
— Functioncommit(conn::Connection)
Commits the current active transaction.
Oracle.rollback
— Functionrollback(conn::Connection)
Rolls back the current active transaction.
Oracle.set_client_identifier
— Functionset_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
Oracle.set_client_info
— Functionset_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
Statement
Oracle.execute
— Functionexecute(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.
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.
Oracle.row_count
— FunctionNumber of affected rows in a DML statement.
Oracle.fetch_array_size!
— Functionfetch_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
— Functionfetch(stmt::Stmt) :: FetchResult
Fetches a single row from the statement.
Variable
Oracle.get_returned_data
— Functionget_returned_data(variable::Variable, pos::Integer) :: Vector
Collects all the data bounded to variable
at position pos
being transfered to and from the database.
Oracle.define
— Functiondefine(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
— Functionchunk_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.
Misc
Oracle.odpi_version
— Functionodpi_version() :: VersionNumber
Returns the underlying odpi library version.