async_statement_execute


Description:

[ Version ( since = "4.2" ) ]
public uint async_statement_execute (Statement stmt, Set? @params, StatementModelUsage model_usage, Type[]? col_types, bool need_last_insert_row) throws Error

This method is similar to statement_execute but is asynchronous as it method returns immediately with a task ID.

It's up to the caller to use async_fetch_result regularly to check if the statement's execution is finished.

It is possible to call the method several times to request several statements to be executed asynchronously, the statements will be executed in the order in which they were requested.

The parameters, if present, are copied and can be discarded or modified before the statement is actually executed. The stmt object is not copied but simply referenced (for performance reasons), and if it is modified before it is actually executed, then its execution will not occur. It is however safe to call unref on it if it's not needed anymore.

The execution failure of any statement has no impact on the execution of other statements except for example if the connection has a transaction started and the failure invalidates the transaction (as decided by the database server).

Note that for asynchronous calls to succeed, it is gererally necessary to specify the THREAD_ISOLATED flag when opening the connection to be sure it is opened in a separate thread in which asynchronous calls are made (failing to use this flag make the asynchronous call dependant on the database provider implementation and at the moment none support this feature).

Parameters:

this

a Connection

stmt

a Statement object

model_usage

in the case where stmt is a SELECT statement, specifies how the returned data model will be used

col_types

an array of GType to request each returned DataModel's column's GType, terminated with the G_TYPE_NONE

need_last_insert_row

TRUE if the values of the last interted row must be computed

params

a Set object (which can be obtained using get_parameters), or null

Returns:

a task ID, or 0 if an error occurred (not an error regarding stmt itself as its execution has not yet started but any other error)




2022 vala-language.org