Beispiel #1
0
//-----------------------------------------------------------------------------
// dpiObject__check() [INTERNAL]
//   Determine if the object handle provided is available for use.
//-----------------------------------------------------------------------------
static int dpiObject__check(dpiObject *obj, const char *fnName,
        dpiError *error)
{
    if (dpiGen__startPublicFn(obj, DPI_HTYPE_OBJECT, fnName, 1, error) < 0)
        return DPI_FAILURE;
    return dpiConn__checkConnected(obj->type->conn, error);
}
//-----------------------------------------------------------------------------
// dpiSodaDocCursor__check() [INTERNAL]
//   Determine if the SODA document cursor is available to use.
//-----------------------------------------------------------------------------
static int dpiSodaDocCursor__check(dpiSodaDocCursor *cursor,
        const char *fnName, dpiError *error)
{
    if (dpiGen__startPublicFn(cursor, DPI_HTYPE_SODA_DOC_CURSOR, fnName, 1,
            error) < 0)
        return DPI_FAILURE;
    if (!cursor->handle)
        return dpiError__set(error, "check closed",
                DPI_ERR_SODA_CURSOR_CLOSED);
    if (!cursor->coll->db->conn->handle || cursor->coll->db->conn->closing)
        return dpiError__set(error, "check connection", DPI_ERR_NOT_CONNECTED);
    return DPI_SUCCESS;
}
//-----------------------------------------------------------------------------
// dpiDeqOptions__setAttrValue() [INTERNAL]
//   Set the attribute value in OCI.
//-----------------------------------------------------------------------------
static int dpiDeqOptions__setAttrValue(dpiDeqOptions *options,
        uint32_t attribute, const char *fnName, const void *value,
        uint32_t valueLength)
{
    dpiError error;
    int status;

    if (dpiGen__startPublicFn(options, DPI_HTYPE_DEQ_OPTIONS, fnName, 1,
            &error) < 0)
        return dpiGen__endPublicFn(options, DPI_FAILURE, &error);
    DPI_CHECK_PTR_NOT_NULL(options, value)
    status = dpiOci__attrSet(options->handle, DPI_OCI_DTYPE_AQDEQ_OPTIONS,
            (void*) value, valueLength, attribute, "set attribute value",
            &error);
    return dpiGen__endPublicFn(options, status, &error);
}
//-----------------------------------------------------------------------------
// dpiDeqOptions_getVisibility() [PUBLIC]
//   Return visibility associated with dequeue options.
//-----------------------------------------------------------------------------
int dpiDeqOptions_getVisibility(dpiDeqOptions *options, dpiVisibility *value)
{
    uint32_t ociValue;
    dpiError error;

    if (dpiGen__startPublicFn(options, DPI_HTYPE_DEQ_OPTIONS, __func__, 1,
            &error) < 0)
        return dpiGen__endPublicFn(options, DPI_FAILURE, &error);
    DPI_CHECK_PTR_NOT_NULL(options, value)
    if (dpiOci__attrGet(options->handle, DPI_OCI_DTYPE_AQDEQ_OPTIONS,
            &ociValue, NULL, DPI_OCI_ATTR_VISIBILITY, "get attribute value",
            &error) < 0)
        return dpiGen__endPublicFn(options, DPI_FAILURE, &error);
    *value = (dpiVisibility) ociValue;
    return dpiGen__endPublicFn(options, DPI_SUCCESS, &error);
}
//-----------------------------------------------------------------------------
// dpiObjectType_getInfo() [PUBLIC]
//   Return information about the object type.
//-----------------------------------------------------------------------------
int dpiObjectType_getInfo(dpiObjectType *objType, dpiObjectTypeInfo *info)
{
    dpiError error;

    if (dpiGen__startPublicFn(objType, DPI_HTYPE_OBJECT_TYPE, __func__, 0,
            &error) < 0)
        return dpiGen__endPublicFn(objType, DPI_FAILURE, &error);
    DPI_CHECK_PTR_NOT_NULL(objType, info)
    info->name = objType->name;
    info->nameLength = objType->nameLength;
    info->schema = objType->schema;
    info->schemaLength = objType->schemaLength;
    info->isCollection = objType->isCollection;
    info->elementTypeInfo = objType->elementTypeInfo;
    info->numAttributes = objType->numAttributes;
    return dpiGen__endPublicFn(objType, DPI_SUCCESS, &error);
}
//-----------------------------------------------------------------------------
// dpiDeqOptions_getMsgId() [PUBLIC]
//   Return message id associated with dequeue options.
//-----------------------------------------------------------------------------
int dpiDeqOptions_getMsgId(dpiDeqOptions *options, const char **value,
        uint32_t *valueLength)
{
    dpiError error;
    void *rawValue;

    if (dpiGen__startPublicFn(options, DPI_HTYPE_DEQ_OPTIONS, __func__, 1,
            &error) < 0)
        return dpiGen__endPublicFn(options, DPI_FAILURE, &error);
    DPI_CHECK_PTR_NOT_NULL(options, value)
    DPI_CHECK_PTR_NOT_NULL(options, valueLength)
    if (dpiOci__attrGet(options->handle, DPI_OCI_DTYPE_AQDEQ_OPTIONS,
            &rawValue, NULL, DPI_OCI_ATTR_DEQ_MSGID, "get attribute value",
            &error) < 0)
        return dpiGen__endPublicFn(options, DPI_FAILURE, &error);
    dpiOci__rawPtr(options->env->handle, rawValue, (void**) value);
    dpiOci__rawSize(options->env->handle, rawValue, valueLength);
    return dpiGen__endPublicFn(options, DPI_SUCCESS, &error);
}
//-----------------------------------------------------------------------------
// dpiDeqOptions_setMsgId() [PUBLIC]
//   Set the message id associated with dequeue options.
//-----------------------------------------------------------------------------
int dpiDeqOptions_setMsgId(dpiDeqOptions *options, const char *value,
        uint32_t valueLength)
{
    void *rawValue = NULL;
    dpiError error;
    int status;

    if (dpiGen__startPublicFn(options, DPI_HTYPE_DEQ_OPTIONS, __func__, 1,
            &error) < 0)
        return dpiGen__endPublicFn(options, DPI_FAILURE, &error);
    DPI_CHECK_PTR_NOT_NULL(options, value)
    if (dpiOci__rawAssignBytes(options->env->handle, value, valueLength,
            &rawValue, &error) < 0)
        return dpiGen__endPublicFn(options, DPI_FAILURE, &error);
    status = dpiOci__attrSet(options->handle, DPI_OCI_DTYPE_AQDEQ_OPTIONS,
            (void*) &rawValue, valueLength, DPI_OCI_ATTR_DEQ_MSGID,
            "set value", &error);
    dpiOci__rawResize(options->env->handle, &rawValue, 0, &error);
    return dpiGen__endPublicFn(options, status, &error);
}