[gnome-db] GdaSqlSelectJoin



Hi!

How to add join to select statement?

What I try is:

GdaSqlStatementSelect *select = valid_select_statement;
GdaSqlSelectFrom *from = select->from;
GdaSqlSelectJoin *join = gda_sql_select_join_new (GDA_SQL_ANY_PART (from));
join->type = GDA_SQL_SELECT_JOIN_LEFT;

GdaSqlExpr *expr = gda_sql_expr_new (GDA_SQL_ANY_PART (join));
expr->value = gda_value_new (G_TYPE_STRING);
g_value_take_string (expr->value, g_strdup ("style"));
join->expr = expr;

GdaSqlField *field_a = gda_sql_field_new (GDA_SQL_ANY_PART (join));
field_a->field_name = g_strdup ("t1.style");
join->use = g_slist_append (join->use, field_a);

GdaSqlField *field_b = gda_sql_field_new (GDA_SQL_ANY_PART (join));
field_b->field_name = g_strdup ("style.id");
join->use = g_slist_append (join->use, field_b);

gda_sql_select_from_take_new_join (from , join);


gda_sql_select_join_serialize (join) returns:
JOIN:
{"join_type":"LEFT","join_pos":"0","on_cond":{"value":"style"},"using":["t1.style","style.id"]}
So I assume join is valid.

However it's not taked into account when statement is executed.

Piotras


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]