[odb-users] How to make an object map to another table (same table structure) ?

Boris Kolpackov boris at codesynthesis.com
Wed Sep 4 10:36:46 EDT 2019


saigut <saigut at qq.com> writes:

> #pragram ......
> calss user_info {
>     int user_id;
>     vchar user_name;
>     int user_age;
> }
> 
> 
> And have such two table:
> user_info_01:
> int user_id, vchar user_name, int user_age
> 
> user_info_02:
> int user_id, vchar user_name, int user_age
> 
> 
> Can I set object of class 'user_info' map to 'user_info_01' or to
> 'user_info_02' ?

No, the best you can do is make user_info a template and then
have two instantiations (using something like a tag to make sure
they are different) mapped to the two tables. But it still has
to be all mapped at compile time.


> In my actual case, my program is going to create one table everyday
> which have the same table structure, those tables are only different
> in table name. So I want to operate those talbes with one class,
> because the  names of all those tables are generate dynamically,
> I can't create classes for every table.

No, this will be difficult to achieve. You could probably come
up with a view to read from such tables but not an object. If you
can change your approach, for example, by adding a column that
indicates a day rather than creating a table, then it will be
easier to map this to ODB.



More information about the odb-users mailing list