Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Foreign key to multiple tables

    I am trying to encode a 3 table query in ds.xml. The first table is joined to 2 others using the same field from the first. Therefore I'm hoping to do something like:

    <field name="ID" type="text" length="11" primaryKey="true" foreignKey="studentPlan.ID" foreignKey="previousTerms.ID">

    This of course seems to not work. Is there a way to specify that a field functions as a foreignKey to multiple other datasources without having to chain the relation through intermediate datasources?

    The query I'm hoping to encode is:

    select
    t1.ID,
    least(min(to_number(t1.TERM,'9999')),min(TO_NUMBER(t2.TERM,'9999'))) as firstTerm
    from UW.STDNT_MULTITERM t1
    left outer join UW.RETENTION_COURSE_HISTORY t2 on t1.ID=t2.ID
    inner join UW.STDNT_PLAN_MULTITERM t3 on t3.ID=t1.ID
    where t1.CAREER='GRAD'
    and t3.PLAN_GROUP='148'
    and t3.PLAN_TYPE='MAJ'
    and t1.TERM='1184'
    GROUP BY t1.ID;

    #2
    I reverted fK and pK in such a setting. This worked fo me, but I'm using INNER JOIN there only.

    Comment


      #3
      I did get this working by specifying <selectClause> and <tableClause> in a custom operation binding. I still need the foreignKey and includeFrom properties to identify fields from other tables though. The trick is to try different xml combinations while watching the server log to see the generated sql and any oracle errors that are generated.

      Comment

      Working...
      X