/usr/share/gtk-doc/html/libgda-5.0/howto-meta1.html is in libgda-5.0-doc 5.2.4-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Get information about a table's columns: GNOME Data Access 5 manual</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="index.html" title="GNOME Data Access 5 manual">
<link rel="up" href="howto.html" title="HOWTO for common tasks">
<link rel="prev" href="ch12s08.html" title="Execute a DDL command">
<link rel="next" href="howto-meta2.html" title="Update the meta data about a table">
<meta name="generator" content="GTK-Doc V1.25 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="5"><tr valign="middle">
<td width="100%" align="left" class="shortcuts"></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td>
<td><a accesskey="u" href="howto.html"><img src="up.png" width="16" height="16" border="0" alt="Up"></a></td>
<td><a accesskey="p" href="ch12s08.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
<td><a accesskey="n" href="howto-meta2.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td>
</tr></table>
<div class="sect1">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="howto-meta1"></a>Get information about a table's columns</h2></div></div></div>
<p>
<span class="application">Libgda</span> supports reporting meta data about a database (for which there is an opened connection). The
meta data are stored in a database (usually an in-memory database) which structure is close to the
information schema SQL standard (ISO/IEC 9075), and adapted (form information, this database is managed by a
<a class="link" href="GdaMetaStore.html" title="GdaMetaStore">GdaMetaStore</a> object). As databases don't notify the changes made to
their objects, it is necessary to update (or synchronize) the meta data if the database's schema has been
changed, or if the meta data has not yet been extracted: call
<a class="link" href="GdaConnection.html#gda-connection-update-meta-store" title="gda_connection_update_meta_storeĀ ()">gda_connection_update_meta_store()</a> for this purpose.
</p>
<p>
One then needs to find the data requested among the (rather large) quantity of meta data available, there are
two possibilities:
</p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem"><p>Knowing the information schema's structure (tables and views) used,
run some SELECT commands on the
<a class="link" href="GdaMetaStore.html" title="GdaMetaStore">GdaMetaStore</a> object's internal connection: this solution is the most
powerful but requires some knowledge of the information schema's structure, and the data
is not easy to use.</p></li>
<li class="listitem"><p>Use a <a class="link" href="GdaMetaStruct.html" title="GdaMetaStruct">GdaMetaStruct</a> object which
<span class="emphasis"><em>exports</em></span> the meta data as a dynamic tree of pre-defined data structures,
easy to use.</p></li>
</ul></div>
<p>
</p>
<p>
The following code shows how to list all the colums of the "customers" table of a connection (the connection
is assumed to already be opened):
</p>
<pre class="programlisting">
GdaMetaStruct *mstruct;
GdaMetaDbObject *dbo;
GValue *table_name;
if (!gda_connection_update_meta_store (cnc, NULL, &error)) {
/* there was an error */
return;
}
mstruct = gda_meta_struct_new (store, GDA_META_STRUCT_FEATURE_NONE);
table_name = gda_value_new (G_TYPE_STRING);
g_value_set_string (value, "customers");
dbo = gda_meta_struct_complement (mstruct, GDA_META_DB_TABLE,
NULL, NULL,
table_name, &error);
gda_value_free (table_name);
if (dbo) {
/* the "customers" table has been found, its details are in dbo */
GdaMetaTable *table = GDA_META_TABLE (dbo);
GSList *list;
for (list = table->columns: list; list = list->next)
g_print ("Column: %s\n", ((GdaMetaTableColumn*) list->data)->column_name);
}
else
g_print ("Table not found\n");
g_object_unref (mstruct);
</pre>
<p>
</p>
</div>
<div class="footer">
<hr>Generated by GTK-Doc V1.25</div>
</body>
</html>
|