gda_meta_context_free (mcontext);
}
- gval = gda_value_new (G_TYPE_STRING);
- g_value_take_string (gval, (gchar *)table_name);
+ /* possibile libgda bug: varchar length is always 0 */
+ /* gval = gda_value_new (G_TYPE_STRING); */
+ /* g_value_take_string (gval, (gchar *)table_name); */
error = NULL;
- dm = gda_connection_get_meta_store_data (priv->gda_conn,
- GDA_CONNECTION_META_FIELDS,
- &error,
- 1,
- "name", gval);
+ /* dm = gda_connection_get_meta_store_data (priv->gda_conn, */
+ /* GDA_CONNECTION_META_FIELDS, */
+ /* &error, */
+ /* 1, */
+ /* "name", gval); */
+
+ GdaMetaStore *mstore;
+ mstore = gda_connection_get_meta_store ((GdaConnection *)gdaex_get_gdaconnection (gdaex));
+ dm = gda_meta_store_extract_v (mstore,
+ g_strdup_printf ("SELECT c.column_name, c.data_type, c.gtype,"
+ " CASE WHEN c.character_maximum_length > 0 THEN c.character_maximum_length ELSE c.numeric_precision END AS numeric_precision,"
+ " c.numeric_scale, c.is_nullable AS Nullable,"
+ " c.column_default, c.extra"
+ " FROM _columns as c NATURAL JOIN _tables as t"
+ " WHERE t.table_short_name='%s'"
+ " ORDER BY c.ordinal_position",
+ table_name),
+ NULL,
+ &error);
if (dm == NULL
|| error != NULL)
error != NULL && error->message != NULL ? error->message : _("no detail."));
}
- gda_value_free (gval);
+ /* gda_value_free (gval); */
return dm;
}
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
+#include <glib/gprintf.h>
+
#include <libgdaex.h>
int
for (rowf = 0; rowf < rowsf; rowf++)
{
g_printf ("\t- %s (%s - %d)\n",
- gdaex_data_model_get_value_stringify_at (dmf, rowf, 0),
- gdaex_data_model_get_value_stringify_at (dmf, rowf, 1),
- gdaex_data_model_get_value_integer_at (dmf, rowf, 3));
+ gdaex_data_model_get_field_value_stringify_at (dmf, rowf, "column_name"),
+ gdaex_data_model_get_field_value_stringify_at (dmf, rowf, "data_type"),
+ gdaex_data_model_get_field_value_integer_at (dmf, rowf, "numeric_precision"));
}
+
+ gchar *dmstr;
+ dmstr = gda_data_model_export_to_string (dmf,
+ GDA_DATA_MODEL_IO_TEXT_TABLE,
+ NULL, 0,
+ NULL, 0,
+ NULL);
+ g_printf ("%s\n",dmstr);
+ g_free (dmstr);
+
g_object_unref (dmf);
}