GdaPstmt

## GdaPstmt GdaPstmt — Base class for prepared statement's |

## Stability Level

Stable, unless otherwise indicated

## Synopsis

    #include <libgda/providers-support/gda-pstmt.h>

    struct              GdaPStmt;
    void                gda_pstmt_set_gda_statement         (GdaPStmt *pstmt,
                                                             GdaStatement *stmt);
    GdaStatement *      gda_pstmt_get_gda_statement         (GdaPStmt *pstmt);
    void                gda_pstmt_copy_contents             (GdaPStmt *src,
                                                             GdaPStmt *dest);

## Object Hierarchy

      GObject
       +----GdaPStmt

## Description

The GdaPStmt represents the association between a GdaStatement statement and a prepared statement which is database dependent and is an in-memory representation of a statement. Using prepared statement has the following advantages:

- the parsing of the SQL has to be done only once, which improves performances if the statement has to be executed more than once

- if a statement has been prepared, then it means it is syntactically correct and has been understood by the database's API

- it is possible to use variables in prepared statement which eliminates the risk of SQL code injection

The GdaPStmt is not intended to be instantiated, but subclassed by database provider's implementation. Once created, the database provider's implementation can decide to associate (for future lookup) to a GdaStatement object in a connection using `gda_connection_add_prepared_statement()`.

The GdaPStmt object can keep a reference to the GdaStatement object (which can be set and get using the `gda_pstmt_set_gda_statement()` and `gda_pstmt_get_gda_statement()`), however that reference if a weak one (which means it will be lost if the GdaStatement object is destroyed).

## Details

### struct GdaPStmt

    struct GdaPStmt;

### gda_pstmt_set_gda_statement ()

    void                gda_pstmt_set_gda_statement         (GdaPStmt *pstmt,
                                                             GdaStatement *stmt);

Informs `pstmt` that it corresponds to the preparation of the `stmt` statement

`pstmt` : | a GdaPStmt object
`stmt` : | a GdaStatement object

### gda_pstmt_get_gda_statement ()

    GdaStatement *      gda_pstmt_get_gda_statement         (GdaPStmt *pstmt);

Get a pointer to the GdaStatement which led to the creation of this prepared statement.

Note: if that statement has been modified since the creation of `pstmt`, then this method will return `NULL`

`pstmt` : | a GdaPStmt object
Returns : | the GdaStatement. [transfer none]

### gda_pstmt_copy_contents ()

    void                gda_pstmt_copy_contents             (GdaPStmt *src,
                                                             GdaPStmt *dest);

Copies `src`'s data to `dest`

`src` : | a GdaPStmt object
`dest` : | a GdaPStmt object