0

我遇到了在数据未按应有方式提取的站点上运行的报告的问题。具体来说,有带有 tlist、From 和 To 日期、Student 和 Sports 的下拉设置。该问题与 Sports 下拉菜单或输出有关。

下拉菜单

<select id="lt" name="lt">
<option value="-1" selected="selected">All Sports</option>
~[tlist_sql;
SELECT DISTINCT log.logtypeid, 
CASE WHEN log.subtype is null THEN ' ' ELSE log.subtype END subID, 
CASE WHEN ','||'~[gpv:lt]'||',' LIKE '%,' || log.subtype || '.' || CASE WHEN 
log.subtype is null THEN ' ' ELSE log.subtype END || ',%' THEN 'selected' ELSE '' END  isselected,
lt.Name logtype, 
CASE WHEN to_char(st.ValueT) is null THEN ' - NONE' ELSE ' - ' || to_char(st.ValueT)    END subtype
FROM log
INNER JOIN gen lt ON log.logtypeid = lt.id
LEFT OUTER JOIN gen st ON st.Name = to_char(lt.ID)
AND st.value = log.subtype
AND st.Cat = 'subtype'
WHERE lt.Cat = 'logtype'
AND log.logtypeid = '3935'
AND to_char(log.schoolid) like CASE WHEN ~(curschoolid) = 0 THEN '%' ELSE to_char(~(curschoolid)) END
ORDER BY subtype
              ;]
                <option value="~(logID;l).~(subtypeID;t)" ~(isselected;t)>~(LogType;t)~ (SubType;t)</option>
              [/tlist_sql]

输出

~[tlist_sql;
SELECT s.Student_Number, s.grade_level, s.lastfirst student, to_char(st.ValueT) subtype, log.discipline_weapontype,
CASE WHEN log.discipline_hearingofficerflag = '1' THEN 'Yes' ELSE ' ' END as pp,
CASE WHEN log.discipline_weaponrelatedflag = '1' THEN 'Yes' ELSE ' ' END  as ss,
DBMS_LOB.SUBSTR(log.entry, 4000,1) Notes
FROM log
INNER JOIN students s ON log.studentid = s.id
~[if#cursel.~[gpv:studentID]=cur]INNER JOIN ~[temp.table.current.selection:students] temp ON temp.dcid=s.dcid[/if#cursel]
INNER JOIN gen lt ON log.logtypeid = lt.id
LEFT OUTER JOIN gen st ON st.Name = to_char(lt.ID)
AND st.value = log.subtype
AND st.Cat = 'subtype'
AND lt.Cat = 'logtype'
WHERE studentid IN
(SELECT studentid
FROM log
WHERE subtype IN
(SELECT subtype
FROM log
WHERE logtypeid = '3935'))
AND subtype IN ('29','43','100','101','102','104','105','106','107','109','110','111','112','113','114','115','116','117','119','120','121','122','123','125','126','127','128','129','130','131','132','133')
AND log.entry_date >= to_date('~[gpv:dateselect]','MM/DD/YYYY')
AND log.entry_date <= to_date('~[gpv:dateselect2]','MM/DD/YYYY')
AND 
~[if#cursel.~[gpv:studentID]#cur]
to_char(s.ID) LIKE CASE WHEN '~[gpv:studentID]' = '-1' THEN '%' ELSE '~[gpv:studentID]' END
[/if#cursel]
AND (
(','||to_char('~[gpv:lt]')||',' LIKE '%,' || to_char(log.logtypeid) || '.' || CASE WHEN log.subtype is null THEN ' ' ELSE log.subtype END || ',%')
OR (','||to_char('~[gpv:lt]')||',' LIKE '%,' || to_char(log.logtypeid) || '.-1,%')
OR (to_char(log.logtypeid) LIKE CASE WHEN to_char('~[gpv:lt]') = '-1' THEN '%' ELSE ','||to_char('~[gpv:lt]')||',' END)
  ) 
ORDER BY s.lastfirst, log.entry_date;alternatecolor]

<tr class="oddRow">
<td>~(count;-)</td>
<td name="stNumCol">~(stNum;t)</td>
<td name="gradeCol">~(grade;t)</td>
<td name="studentCol">~(Student;t)</td>
<td name="subtypeCol">~(st;t)</td>
<td name="dopCol">~(date of physical;t)&nbsp;</td>
<td name="ppCol">~(parent perm.;t)&nbsp;</td>
<td name="ssCol">~(student signa.;t)</td>
<td name="notesCol">~(notes;t)</td>
</tr>
[/tlist_sql]

当报告在选择所有运动的情况下运行时,它会拉出所有拥有运动日志的学生

log.logtypeid = '3935'

或者他们也可以是

log.subtype IN ('100','101','102','104','105','106','107','109','110','111','112','113','114','115','116','117','119','120','121','122','123','125','126','127','128','129','130','131','132','133')

需要提取另一组数据,子类型“29”和“43”,它们是健康日志。29 代码使某人无法参加一项运动,而 43 则使他们能够。

问题

运行所有运动时,它会显示所有学生的运动日志,并且还会显示学生 29 和 43 的代码。但是从下拉列表中选择单个运动时,它不会显示那些学生的 29 和 43 健康日志子类型。

任何意见或建议将不胜感激。谢谢

4

1 回答 1

0

以下是阅读您遇到问题的符号的方法:

  • || 表示Oracle(以及 Java 和 C# 等语言)中的连接,所以在你看到的任何地方 || 在两个语句之间意味着系统将它们作为一个来读取。
  • Case 语句本质上是 SQL 的 if/then 语句。Case 定义要检查的内容,然后 When 和 Else 说明如何处理特定场景。
  • to_char ('') 语句列表在最有可能使用的周围字符串上放置特定的字符格式,以便您可以连接元数据。
  • %LIKE语句所需的通配符

当您更改格式时,此代码更有意义:

AND (
    (','||to_char('~[gpv:lt]')||',' LIKE '%,' || to_char(log.logtypeid) || '.' || 
        CASE WHEN log.subtype is null 
        THEN ' ' 
        ELSE log.subtype 
        END || ',%')
 OR (','||to_char('~[gpv:lt]')||',' LIKE '%,' || to_char(log.logtypeid) || '.-1,%')
 OR (to_char(log.logtypeid) LIKE 
        CASE 
        WHEN to_char('~[gpv:lt]') = '-1' 
        THEN '%' 
        ELSE ','||to_char('~[gpv:lt]')||',' 
        END)  
) 

所以基本上它是检查andgpv:lt LIKE的值(当有一个子类型 - 也就是不为空时)它检查什么时候或 = 到if not = 1。log.logtypeidlog.subtypeORgpv:lt LIKE log.logtypeid.-1 ORlog.logtypeid LIKEgpv:lt = -1gpv:lt

请注意,我不知道这对您的申请/报告意味着什么,因为我不明白您要完成的工作的逻辑......但希望上面的英文陈述可以帮助您翻译您的问题。

于 2014-08-20T15:07:42.443 回答