Ticket #394 (closed enhancement: fixed)

Opened 5 years ago

Last modified 2 weeks ago

Oracle OCI, support for views.

Reported by: llo@carlbro.dk Assigned to: warmerdam
Priority: high Milestone:
Component: OGR_SF Version: unspecified
Severity: minor Keywords:
Cc: mloskot

Description (Last modified by mloskot)

I started to use the OGR OCI driver from Mapserver, and I found some things in the driver that could be better:

As far as I can tell, the driver does not give me the posibility to specify the feature_id column name. It seems that it is hardcoded to "OGR_FID" in the driver. So I created a view in Oracle with the OGR_FID column using my unique ID, but that didn't help - the driver does not support views. So I changed the ReadTableDefinition? in ogrocitablelayer.cpp so that it supports views, and voila it works.

Here is the changed code from ogrocitablelayer.cpp, ReadTableDefinition?:

Original code:

nStatus = OCIDescribeAny( poSession->hSvcCtx, poSession->hError, (dvoid *) pszTable, strlen(pszTable), OCI_OTYPE_NAME, OCI_DEFAULT, OCI_PTYPE_TABLE, poSession->hDescribe );

if( poSession->Failed( nStatus, "OCIDescribeAny" ) )
    return poDefn;

Changed code:

nStatus = OCIDescribeAny( poSession->hSvcCtx, poSession->hError, (dvoid *) pszTable, strlen(pszTable), OCI_OTYPE_NAME, OCI_DEFAULT, OCI_PTYPE_TABLE, poSession->hDescribe );

if( poSession->Failed( nStatus, "OCIDescribeAny" ) )
{
    nStatus = OCIDescribeAny( poSession->hSvcCtx, poSession->hError, (dvoid *) pszTable, strlen(pszTable), OCI_OTYPE_NAME, OCI_DEFAULT, OCI_PTYPE_VIEW, poSession->hDescribe );

    if( poSession->Failed( nStatus, "OCIDescribeAny" ) )
        return poDefn;
}

Best regards Lars Loldrup

Change History

09/18/03 12:35:20 changed by warmerdam

Lars, 

I have applied and tested your view patch. 

Thanks!

As you discovered, there is a general issue with the Oracle driver, that it is
not currently possible to pass information to the oracle driver to modify how
it maps oracle stuff into a form expected by OGR.  

I may well add the ability to provide OGR a "control file" or something like
that which will support additional options, such as what tables to make visible
as layers, what geometry column to use (if there are more than one), and how
what to use for FID. 



08/06/08 10:02:41 changed by mloskot

  • cc set to mloskot.
  • description changed.