XMLWordPrintableJSON

Details

    • New Feature
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 2.1.7
    • None
    • Core
    • None

    Description

      I have the following problem: I include the same SQL snippet from
      multiple select statements, some of them for completely unrelated
      tables. This is done because these tables contain quite a few columns
      with the same names in both tables.

      <sql id="inc">
      name,
      value,
      foo,
      bar
      </sql>

      <select id="loadA">
      select id,
      <include refid="inc" />
      from A
      </select>

      <select id="loadB">
      select id,
      <include refid="inc" />
      from B
      </select>

      When including the list of columns, it would be quite handy to add a
      parameter to the include, for example to set a table alias in case I
      have a join between tables:

      <select id="loadA">
      select a.id, b.id,
      <include refid="inc" />
      from A a
      inner join B b on (b.id = a.id)
      where b.baz = #baz#
      </select>

      In the above query, "name", "value" etc are no longer unique in the
      query, most of the time you end up with the wrong values.

      It would be great if I would be able to pass in a parameter to the
      include, e.g.:

      <select id="loadA">
      select a.id, b.id,
      <include refid="inc" param="a."/>
      from A a
      inner join B b on (b.id = a.id)
      where b.baz = #baz#
      </select>

      so I could have the SQL snippet defined like this:

      <sql id="inc">
      $param$name,
      $param$value,
      $param$foo,
      $param$bar
      </sql>

      This way, all of the statements would still work and I could make sure
      that the correct columns are used in each case.

      Attachments

        Activity

          People

            Unassigned Unassigned
            nwinkler Nils Winkler
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: