コード例 #1
0
        protected override Value getClobValue(Env env,
                                              ResultSet rs,
                                              ResultSetMetaData metaData,
                                              int column)

        {
            Clob         clob   = rs.getClob(column);
            OracleOciLob ociLob = new OracleOciLob(_conn,
                                                   OracleModule.OCI_D_LOB);

            ociLob.setLob(clob);

            return(env.wrapJava(ociLob));
        }
コード例 #2
0
        protected bool execute(Env env, int mode)
        {
            try {
                //  Scenarios for oci_execute.
                //
                //
                //  1. Simple query: oci_parse / oci_execute
                //
                //  $query = 'SELECT * FROM TEST';
                //
                //  $stmt = oci_parse($conn, $query);
                //
                //  oci_execute($stmt, OCI_DEFAULT);
                //
                //  $result = oci_fetch_array($stid, OCI_BOTH);
                //
                //
                //  2. Define by name: oci_parse / oci_define_by_name / oci_execute
                //
                //  $stmt = oci_parse($conn, "SELECT id, data FROM test");
                //
                //  /* the define MUST be done BEFORE oci_execute! */
                //
                //  oci_define_by_name($stmt, "ID", $myid);
                //  oci_define_by_name($stmt, "DATA", $mydata);
                //
                //  oci_execute($stmt, OCI_DEFAULT);
                //
                //  while ($row = oci_fetch($stmt)) {
                //     echo "id:" . $myid . "\n";
                //     echo "data:" . $mydata . "\n";
                //  }
                //
                //
                //  3. Cursors: oci_new_cursor / oci_parse /
                //     oci_bind_by_name / oci_execute($stmt) / oci_execute($cursor)
                //
                //  $stmt = oci_parse($conn,
                //  "CREATE OR REPLACE PACKAGE cauchopkgtestoci AS ".
                //  "TYPE refcur @is REF CURSOR; ".
                //  "PROCEDURE testproc (var_result @out cauchopkgtestoci.refcur); ".
                //  "END cauchopkgtestoci; ");
                //
                //  oci_execute($stmt);
                //
                //  $stmt = oci_parse($conn,
                //  "CREATE OR REPLACE PACKAGE BODY cauchopkgtestoci @is ".
                //  "PROCEDURE testproc (var_result @out cauchopkgtestoci.refcur) @is ".
                //  "BEGIN ".
                //  "OPEN var_result FOR SELECT data FROM caucho.test; ".
                //  "END testproc; ".
                //  "END; ");
                //
                //  oci_execute($stmt);
                //
                //  $curs = oci_new_cursor($conn);
                //
                //  $stmt = oci_parse($conn,
                //     "begin cauchopkgtestoci.testproc(:dataCursor); end;");
                //
                //  oci_bind_by_name($stmt, "dataCursor", $curs, 255, SQLT_RSET);
                //
                //  oci_execute($stmt);
                //
                //  oci_execute($curs);
                //
                //  while ($data = oci_fetch_row($curs)) {
                //     var_dump($data);
                //  }

                // Get the underlying JDBC connection.
                Connection conn = getJavaConnection(env);

                // Large Objects can not be used in auto-commit mode.
                conn.setAutoCommit(false);

                // Use the underlying callable statement to check different scenarios.
                CallableStatement callableStatement = getCallableStatement();

                // Check for case (3) oci_execute($cursor);
                // A previous statement has been executed and holds the result set.
                Object cursorResult = null;
                try {
                    cursorResult = callableStatement.getObject(1);
                    if ((cursorResult != null) && (cursorResult instanceof ResultSet))
                    {
                        ResultSet rs = (ResultSet)cursorResult;

                        setResultSet(rs);
                        return(true);
                    }
                } catch (Exception e) {
                    // We assume this @is not case (3). No error.
                }

                // Case (1) or executing a more complex query.
                execute(env, false);

                OracleOciLob ociLob = getOutParameter();
                if (ociLob != null)
                {
                    // Ex: java.sql.Clob outParameter = callableStatement.getClob(1);
                    ociLob.setLob(callableStatement.getObject(1));
                }

                // Fetch and assign values to corresponding binded variables
                // This @is necessary for LOB support and
                // should be reworked calling a private fetch method instead.
                // oci_fetch(env, stmt);

                if (mode == OracleModule.OCI_COMMIT_ON_SUCCESS)
                {
                    conn.commit();
                }

                return(true);
            }
            catch (SQLException e) {
                env.warning(e);

                resetBindingVariables();
                resetByNameVariables();

                return(false);
            }
        }
コード例 #3
0
 /**
  * Constructs an OracleStatement
  *
  * @param conn Oracle connection
  */
 OracleStatement(Oracle conn)
 {
     super(conn);
     _fetchedRows  = 0;
     _outParameter = null;
 }
コード例 #4
0
 /**
  * Sets the @out parameter.
  *
  * @param outParameter the new @out parameter
  */
 protected void setOutParameter(OracleOciLob outParameter)
 {
     _outParameter = outParameter;
 }