incubator-empire-db-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rainer Döbele <doeb...@esteam.de>
Subject re: Add one table from a different schema
Date Thu, 12 Jan 2012 19:58:24 GMT
Hello Alain,

the solution is simple: for each schema you need a separate database object i.e. in your case
you need two classes derived from DBDatabase that define the corresponding table(s).

The constructor of DBDatabase allows to supply a schema name.
When you join, the schema name will always be prepended.

IMO it does not make sense to define tables of a different schema in a single DBDatabase (however
I must admit, that the class therefore should rather be called DBSchema than DBDatabase).

If you use Oracle it is even possible to work with Database Links like that. The schema (in
Oracle the user) is prepended, the Link is appended to the table or view name.

Hope you found my answer helpful.

Regards,
Rainer


> from: Alain Becam [mailto:Alain.Becam@embl.de]
> to: empire-db-user@incubator.apache.org
> re: Add one table from a different schema
> 
> Hello,
>       I want to do something like that:
> 
> SELECT t10.name
> FROM schema2.person t10 INNER JOIN personInGroup t11 ON t11.ID =
> t10.group_ID WHERE t11.ID LIKE 'C12'
> 
> Where the person table in in another schema where I have the "SELECT"
> rights. And I cannot get it to work. I could use a view, but it should
> be possible without. I have seen in DBDatabase the setSchema, but it
> looks global. I was expecting a way to define that in the table
> definition (something like public tableName(DBDatabase theDB){
> super("nameOfTable","nameOfSchema",theDB);), but it does not look
> possible. So I guess I am totally in the wrong here :)
> 
> Also, I asked some time ago another simple questions, maybe the answers
> should be added in the wiki? I could actually do a part of it if you'd
> like (EmpireDB for dummies :) ).
> Thank for your help,
>     Alain

Mime
View raw message