TrackerSparqlStatement: Tracker SPARQL Library Reference Manual

## TrackerSparqlStatement TrackerSparqlStatement — Prepared statements |

## Stability Level

Stable, unless otherwise indicated

## Functions

TrackerSparqlCursor * | tracker_sparql_statement_execute ()
void | tracker_sparql_statement_execute_async ()
TrackerSparqlCursor * | tracker_sparql_statement_execute_finish ()
void | tracker_sparql_statement_bind_int ()
void | tracker_sparql_statement_bind_double ()
void | tracker_sparql_statement_bind_string ()
void | tracker_sparql_statement_bind_boolean ()
void | tracker_sparql_statement_clear_bindings ()
TrackerSparqlConnection * | tracker_sparql_statement_get_connection ()
const gchar * | tracker_sparql_statement_get_sparql ()

## Properties

TrackerSparqlConnection * | connection | Read / Write / Construct Only
char * | sparql | Read / Write / Construct Only

## Types and Values

| TrackerSparqlStatement

## Object Hierarchy

        GObject
        ╰── TrackerSparqlStatement

## Includes

    #include <tracker-sparql.h>

## Description

The TrackerSparqlStatement object represents a SPARQL query. This query may contain parameterized variables (expressed as ~var in the syntax), which may be mapped to arbitrary values prior to execution. This statement may be reused for future queries with different values.

The argument bindings may be changed through `tracker_sparql_statement_bind_int()`, `tracker_sparql_statement_bind_boolean()`, `tracker_sparql_statement_bind_double()` and `tracker_sparql_statement_bind_string()`. Those functions receive a `name` argument corresponding for the variable name in the SPARQL query (eg. "var" for ~var) and a `value` to map the variable to.

Once all arguments have a value, the query may be executed through `tracker_sparql_statement_execute()` or `tracker_sparql_statement_execute_async()`.

This object was added in Tracker 2.2.

## Functions

### tracker_sparql_statement_execute ()

    TrackerSparqlCursor *
    tracker_sparql_statement_execute (TrackerSparqlStatement *stmt,
                                      GCancellable *cancellable,
                                      GError **error);

Executes the SPARQL query with the currently bound values.

#### Parameters

stmt | a TrackerSparqlStatement |
cancellable | a GCancellable used to cancel the operation |
error | GError for error reporting. |

#### Returns

A TrackerSparqlCursor.

[transfer full]

### tracker_sparql_statement_execute_async ()

    void
    tracker_sparql_statement_execute_async
                                   (TrackerSparqlStatement *stmt,
                                    GCancellable *cancellable,
                                    GAsyncReadyCallback callback,
                                    gpointer user_data);

Asynchronously executes the SPARQL query with the currently bound values.

#### Parameters

stmt | a TrackerSparqlStatement |
cancellable | a GCancellable used to cancel the operation |
callback | user-defined GAsyncReadyCallback to be called when asynchronous operation is finished. |
user_data | user-defined data to be passed to `callback` |

### tracker_sparql_statement_execute_finish ()

    TrackerSparqlCursor *
    tracker_sparql_statement_execute_finish
                                   (TrackerSparqlStatement *stmt,
                                    GAsyncResult *res,
                                    GError **error);

Finishes the asynchronous operation started through `tracker_sparql_statement_execute_async()`.

#### Parameters

stmt | a TrackerSparqlStatement |
res | The GAsyncResult from the callback used to return the TrackerSparqlCursor |
error | The error which occurred or `NULL` |

#### Returns

A TrackerSparqlCursor.

[transfer full]

### tracker_sparql_statement_bind_int ()

    void
    tracker_sparql_statement_bind_int (TrackerSparqlStatement *stmt,
                                       const gchar *name,
                                       gint64 value);

Binds the integer `value` to variable `name` .

#### Parameters

stmt | a TrackerSparqlStatement |
name | variable name |
value | value |

### tracker_sparql_statement_bind_double ()

    void
    tracker_sparql_statement_bind_double (TrackerSparqlStatement *stmt,
                                          const gchar *name,
                                          gdouble value);

Binds the double `value` to variable `name` .

#### Parameters

stmt | a TrackerSparqlStatement |
name | variable name |
value | value |

### tracker_sparql_statement_bind_string ()

    void
    tracker_sparql_statement_bind_string (TrackerSparqlStatement *stmt,
                                          const gchar *name,
                                          const gchar *value);

Binds the string `value` to variable `name` .

#### Parameters

stmt | a TrackerSparqlStatement |
name | variable name |
value | value |

### tracker_sparql_statement_bind_boolean ()

    void
    tracker_sparql_statement_bind_boolean (TrackerSparqlStatement *stmt,
                                           const gchar *name,
                                           gboolean value);

Binds the boolean `value` to variable `name` .

#### Parameters

stmt | a TrackerSparqlStatement |
name | variable name |
value | value |

### tracker_sparql_statement_clear_bindings ()

    void
    tracker_sparql_statement_clear_bindings
                                   (TrackerSparqlStatement *stmt);

Clears all boolean/string/integer/double bindings.

#### Parameters

stmt | a TrackerSparqlStatement |

Since: 3.0

### tracker_sparql_statement_get_connection ()

    TrackerSparqlConnection *
    tracker_sparql_statement_get_connection
                                   (TrackerSparqlStatement *stmt);

Returns the TrackerSparqlConnection that this statement was created from.

#### Parameters

stmt | a TrackerSparqlStatement |

#### Returns

The SPARQL connection of this statement.

[transfer none]

### tracker_sparql_statement_get_sparql ()

    const gchar *
    tracker_sparql_statement_get_sparql (TrackerSparqlStatement *stmt);

Returns the SPARQL string that this prepared statement holds.

#### Parameters

stmt | a TrackerSparqlStatement |

#### Returns

The contained SPARQL query

## Types and Values

### TrackerSparqlStatement

    typedef struct _TrackerSparqlStatement TrackerSparqlStatement;

The TrackerSparqlStatement object represents a prepared query statement.

## Property Details

### The `“connection”` property

      “connection”               TrackerSparqlConnection *

The TrackerSparqlConnection used to perform the query.

Owner: TrackerSparqlStatement

Flags: Read / Write / Construct Only

### The `“sparql”` property

      “sparql”                   char *

SPARQL query stored in this statement.

Owner: TrackerSparqlStatement

Flags: Read / Write / Construct Only

Default value: NULL