Problem with Oracle selecting object types

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • sam.lumbroso@gmail.com

    #1

    Problem with Oracle selecting object types

    I have the following object type created in Oracle (OCI8):

    create or replace type address as object
    (
    address VARCHAR2(80),
    city VARCHAR2(80),
    state VARCHAR2(20),
    zip VARCHAR2(10)
    )

    and I have the following table created:

    create table test
    (
    address ADDRESS
    )

    and when I run this:

    $sql = "SELECT * FROM test";
    $s = ociparse(O_CON, $sql);
    ociexecute($s);

    I get this error:

    Warning: ociexecute(): OCIDefineByPos: ORA-00932: inconsistent
    datatypes in /home/httpd/html/stats/test.php on line (the ociexecute
    line)

    Can I not select custom types from Oracle or is there something else I
    have to do?

  • Mladen Gogala

    #2
    Re: Problem with Oracle selecting object types

    On Wed, 19 Jul 2006 16:29:38 -0700, sam.lumbroso wrote:
    I have the following object type created in Oracle (OCI8):
    >
    create or replace type address as object
    (
    address VARCHAR2(80),
    city VARCHAR2(80),
    state VARCHAR2(20),
    zip VARCHAR2(10)
    )
    >
    and I have the following table created:
    >
    create table test
    (
    address ADDRESS
    )
    >
    and when I run this:
    >
    $sql = "SELECT * FROM test";
    $s = ociparse(O_CON, $sql);
    ociexecute($s);
    >
    I get this error:
    >
    Warning: ociexecute(): OCIDefineByPos: ORA-00932: inconsistent
    datatypes in /home/httpd/html/stats/test.php on line (the ociexecute
    line)
    >
    Can I not select custom types from Oracle or is there something else I
    have to do?
    Sam, I haven't ever done named types, but I would try using OCI8 instead
    of using OCI and I would try oci_define_by_n ame with OCI_NTY bind type.
    I'm not sure that OCI supports object type bindings and I am sure that OCI
    is deprecated.

    --
    大红鹰娱乐平台采用顶级加密技术,确保用户数据与交易的安全无虞,让玩家能够放心畅玩。


    Comment

    • Mladen Gogala

      #3
      Re: Problem with Oracle selecting object types

      sam.lumbroso@gm ail.com wrote:
      I have the following object type created in Oracle (OCI8):
      >
      create or replace type address as object
      (
      address VARCHAR2(80),
      city VARCHAR2(80),
      state VARCHAR2(20),
      zip VARCHAR2(10)
      )
      >
      and I have the following table created:
      >
      create table test
      (
      address ADDRESS
      )
      >
      and when I run this:
      >
      $sql = "SELECT * FROM test";
      $s = ociparse(O_CON, $sql);
      ociexecute($s);
      >
      I get this error:
      >
      Warning: ociexecute(): OCIDefineByPos: ORA-00932: inconsistent
      datatypes in /home/httpd/html/stats/test.php on line (the ociexecute
      line)
      >
      Can I not select custom types from Oracle or is there something else I
      have to do?
      >
      It will not work. It works only for VARRAY types. Here is what happens:

      <?php
      $tns = "TESTDB01";
      $u = "mgdba";
      $p = "qwerty";
      $dbh = oci_connect($u, $p, $tns);
      if (!$addr = oci_new_collect ion($dbh, 'ADDRESS')) {
      die("Cannot allocate ADT descriptor for this type\n");
      }
      $query = "select address into :addr from test";
      $sth = oci_parse($dbh, $query);
      oci_bind_by_nam e($sth, ":addr", $addr, -1, SQLT_NTY);
      oci_execute($st h);
      while (oci_fetch($sth )) {
      var_dump($addr) ;
      }
      ?>


      bash-3.1$ php object.php

      Warning: oci_new_collect ion(): ORA-22318: input type is not an array
      type in c:\tmp\object.p hp on line 6
      Cannot allocate ADT descriptor for this type
      bash-3.1$
      >oerr ora 22318
      22318, 00000, "input type is not an array type"
      // *Cause: The user is trying to obtain the number of elements for a
      // non-array type.
      // *Action: Pass in only a named collection type which is an array.


      This is PHP 5.1.4 on Apache 2.0.54. It will, probably, be supported in
      later releases.
      --
      Mladen Gogala
      大红鹰娱乐平台采用顶级加密技术,确保用户数据与交易的安全无虞,让玩家能够放心畅玩。

      Comment

      • sam.lumbroso@gmail.com

        #4
        Re: Problem with Oracle selecting object types

        Thank you for the response, Mladen. Fortunately, it is not crucial, I
        was just looking to simplify my work.

        Comment

        Working...