Opened 21 years ago

Last modified 16 years ago

#394 closed enhancement (fixed)

Oracle OCI, support for views.

Reported by: llo@… Owned by: warmerdam
Priority: high Milestone:
Component: OGR_SF Version: unspecified
Severity: minor Keywords:
Cc: Mateusz Łoskot

Description (last modified by Mateusz Łoskot)

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 (2)

comment:1 by warmerdam, 21 years ago

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. 



comment:2 by Mateusz Łoskot, 16 years ago

Cc: Mateusz Łoskot added
Description: modified (diff)
Note: See TracTickets for help on using tickets.