'Provides a proper substitution value for Geometries that are not in the
SRID of the field.  Specifically, this routine will substitute in the
SDO_CS.TRANSFORM() function call.'

def get_geom_placeholder(self, f, value):

    if (value is None):
        return 'NULL'
    def transform_value(val, srid):
        return (val.srid != srid)
    if hasattr(value, 'expression'):
        if transform_value(value, f.srid):
            placeholder = ('%s(%%s,    %s)' % (self.transform, f.srid))
        else:
            placeholder = '%s'
        return ((placeholder % '%s.%s') % tuple(map(self.quote_name, value.cols[value.expression])))
    elif transform_value(value, f.srid):
        return ('%s(SDO_GEOMETRY(%%s,    %s),    %s)' % (self.transform, value.srid, f.srid))
    else:
        return ('SDO_GEOMETRY(%%s,    %s)' % f.srid)
