Re: [gnome-db] Gda Column question.





2008/10/8 Bas Driessen <bas driessen xobas com>
On Thu, 2008-10-02 at 20:50 +0200, Vivien Malerba wrote:


2008/10/1 Vivien Malerba <vmalerba gmail com>


2008/10/1 Daniel Espinosa <esodan gmail com>

In V4 you have GdaMetaStore to get columns and others db objects information. In order to get that information you have to do:

- Get a GdaMetaStore from a GdaConnnection using gda_connection_get_meta_store
- Update meta information gda_connection_update_meta_store
- Get columns information using gda_meta_store_extract and use GdaDataModel API to access to the required information

The required SQL to do it could be:

SELECT *  FROM _columns WHERE table_schema = ##schema::string AND table_catalog = ##catalog::string AND table_name = ##table::string

For gda_column_get_scale you can use numeric_scale column; sorry but don't know about defined_size.


You can use the numeric_precision or numeric_scale columns, with both these columns you should have all the characteristics of a column.
Now, this was to get meta data information. I agree that I've been a bit too quick in simplifying the GdaColumn API and I should bring back the API which handles numeric presicion and scale, but probably not as it was. Let me think about it.


In Rev #3221, I've added functions to set any attribute (as (name, value) pairs) to GdaColumn, GdaHolder and the GdaMetaTableColumn, which means those 3 types of objects (well the last one is not an object) can pass onto the other attributes. For example when creating a GdaDataModelIter, the attributes for each GdaHolder are set from those of the corresponding GdaColumn of the data model the iter is for.

Looking at these new gda_column_get/set_attribute functions. Still it is not clear to me how to get the size and scale of a column. Again, in V3,  I just use gda_column_get_defined_size and gda_column_get_scale and done. Can you please give a small example/snippet how to use this with these new functions?  How/where can I find out about the attribute names?

const GValue *value;
value = gda_column_get_attribute (column, GDA_ATTRIBUTE_NUMERIC_SCALE);
You can use any of the predefined attribute names in gda-attributes-manager.h

However, these attributes are not yet AFAIK set by any database provider.

For GdaColumn attributes, the problem is that database API usually don't return that kind of information, and the only way of getting it is using meta data, specifically when a SELECT statement is executed, then libgda should use the meta data is has to set (or complement) those attributes for each column of the returned data model. However this has a cost in term of performances (as meta data need to be consulted) so it's not done (it's done only when creating a GdaDataModelIter, setting the attributes for the GdaHolder corresponding to each column). Maybe a solution will be to add a GdaDataSelect method to request column's attributes to be computed, but this for a later version.

For GdaHolder objects, as I just explained, some attributes are set in the set_holders_properties_from_select_stmt() function in gda-data-model-iter.c, but it needs to be completed to set the attributes you are interrested in.

Cheers,

Vivien




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