1 Reply Latest reply on Feb 25, 2019 5:54 PM by d2e0530b-e6d0-4597-838c-aadcb9126215

    OCI_ATTR_LIST_SCHEMAS

    d2e0530b-e6d0-4597-838c-aadcb9126215

      Hello, I'm new here.

       

      The documentation here:

       

      https://docs.oracle.com/en/database/oracle/oracle-database/18/lnoci/describing-schema-metadata.html#GUID-BFB18B6E-E306-4…

       

      describes the database attributes available through OCIGetAttr().  One of them is OCI_ATTR_LIST_SCHEMAS, which claims to return a ub1 datatype, representing a "list of schemas".  Already, that looks like a typo and should be OCIParam *, similar to LIST_COLUMNS on a table.  I was even able to get the attribute into an OCIParam * and could iterate through the schemas one, by one, using subsequent calls to OCIParamGet() on the returned pointer.

       

      The real problem is, there's no length associated with the list.  For example, OCI_ATTR_LIST_COLUMNS also has a companion OCI_ATTR_NUM_COLS to help me know ahead of time how many to expect.  My only recourse in LIST_SCHEMAS is to keep trying until the return code from OCIGetAttr is no longer OCI_SUCCESS, which seems kludgy. 

       

      Are these doc bugs, and how should I approach this?

       

      Thanks!

        • 1. Re: OCI_ATTR_LIST_SCHEMAS
          d2e0530b-e6d0-4597-838c-aadcb9126215

          So, I'm answering my own question, in case anyone else has it.

           

          I do, still believe, the documentation shows the incorrect return type and it should be an OCIParam * and not a ub2.

           

          However, all "List Attributes" that you get back with OCIGetAttr(), including OCI_ATTR_LIST_SCHEMAS, OCI_ATTR_LIST_OBJECTS and OCI_ATTR_LIST_COLUMNS allow you to call OCIAttr() on their parameter handle.  If you call OCIGetAttr() with the attribute OCI_ATTR_NUM_PARAMS, it will let you know how many elements there are in the list.  Otherwise, iterating over an empty list will result in a segfault.

           

          This is outlined in "8.2.12 List Attributes" section.