1 /* 2 * Copyright (C) 2008 - 2011 Vivien Malerba <malerba@gnome-db.org> 3 * Copyright (C) 2009 Murray Cumming <murrayc@murrayc.com> 4 * 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Lesser General Public 7 * License as published by the Free Software Foundation; either 8 * version 2 of the License, or (at your option) any later version. 9 * 10 * This library is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public 16 * License along with this library; if not, write to the 17 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, 18 * Boston, MA 02110-1301, USA. 19 */ 20 21 #ifndef _GDA_STATEMENT_STRUCT_INSERT_H_ 22 #define _GDA_STATEMENT_STRUCT_INSERT_H_ 23 24 #include <glib.h> 25 #include <glib-object.h> 26 #include <sql-parser/gda-statement-struct-decl.h> 27 #include <sql-parser/gda-statement-struct-select.h> 28 #include <sql-parser/gda-statement-struct-parts.h> 29 30 G_BEGIN_DECLS 31 32 /* 33 * Structure definition 34 */ 35 /** 36 * GdaSqlStatementInsert: 37 * @any: inheritance structure 38 * @on_conflict: conflict resolution clause if there is one (such as "OR REPLACE") 39 * @table: name of the table to which data is inserted 40 * @fields_list: list of #GdaSqlField fields which are valued for insertion 41 * @values_list: list of list of #GdaSqlExpr expressions (this is a list of list, not a simple list) 42 * @select: a #GdaSqlStatementSelect or #GdaSqlStatementCompound structure representing the values to insert 43 * 44 * The statement is an INSERT statement, any kind of INSERT statement can be represented using this structure 45 * (if this is not the case 46 * then report a bug). 47 * <mediaobject> 48 * <imageobject role="html"> 49 * <imagedata fileref="stmt-insert1.png" format="PNG"/> 50 * </imageobject> 51 * <caption> 52 * <para> 53 * Example of a #GdaSqlStatement having a #GdaSqlStatementInsert as its contents with 2 lists of values 54 * to insert. 55 * </para> 56 * </caption> 57 * </mediaobject> 58 * <mediaobject> 59 * <imageobject role="html"> 60 * <imagedata fileref="stmt-insert2.png" format="PNG"/> 61 * </imageobject> 62 * <caption> 63 * <para> 64 * Another example of a #GdaSqlStatement having a #GdaSqlStatementInsert as its contents, using a SELECT 65 * to express the values to insert. 66 * </para> 67 * </caption> 68 * </mediaobject> 69 */ 70 struct _GdaSqlStatementInsert { 71 GdaSqlAnyPart any; 72 gchar *on_conflict; /* conflict resolution clause */ 73 GdaSqlTable *table; 74 GSList *fields_list; /* list of GdaSqlField structures */ 75 GSList *values_list; /* list of list of GdaSqlExpr */ 76 GdaSqlAnyPart *select; /* SELECT OR COMPOUND statements: GdaSqlStatementSelect or GdaSqlStatementCompound */ 77 78 /*< private >*/ 79 /* Padding for future expansion */ 80 gpointer _gda_reserved1; 81 gpointer _gda_reserved2; 82 }; 83 84 /* 85 * Common operations 86 */ 87 GdaSqlStatementContentsInfo *_gda_sql_statement_insert_get_infos (void); 88 89 /* 90 * Functions used by the parser 91 */ 92 void gda_sql_statement_insert_take_table_name (GdaSqlStatement *stmt, GValue *value); 93 void gda_sql_statement_insert_take_on_conflict (GdaSqlStatement *stmt, GValue *value); 94 void gda_sql_statement_insert_take_fields_list (GdaSqlStatement *stmt, GSList *list); 95 void gda_sql_statement_insert_take_1_values_list (GdaSqlStatement *stmt, GSList *list); 96 void gda_sql_statement_insert_take_extra_values_list (GdaSqlStatement *stmt, GSList *list); 97 98 void gda_sql_statement_insert_take_select (GdaSqlStatement *stmt, GdaSqlStatement *select); 99 100 G_END_DECLS 101 102 #endif 103