我正在Oracle Apex中构建堆叠列3D Flash图表。它基于PL / SQL返回SQL查询。需要PL / sql来捕获所有类型的属性,并计算连接到这些属性的数据库中的实例数。代码是:
DECLARE
l_qry VARCHAR2(32767);
v_id NUMBER;
v_resort VARCHAR2(80);
BEGIN
l_qry := 'SELECT ''fp=&APP_ID.:802::app_session::::P5_SEARCH_MONTH:''||TO_CHAR(E.ENQUIRED_DATE,''MON-YY'')||'':'' link,';
l_qry := l_qry || ''' ''||TO_CHAR(E.ENQUIRED_DATE,''MON-YY'')||'':'' label,';
--Loop through the resorts and add a sum(decode...) column with column alias
FOR r1 IN (SELECT DISTINCT a.resort_id FROM enquiry a, resort b where a.resort_id IS NOT NULL and a.resort_id = b.id and b.active =1)
LOOP
select name into v_resort
from resort
where id = r1.resort_id;
现在发生了什么PLSQL正在通过所有度假村并计算它们。这个解决方案在某种程度上确实有效,但是在返回值之后我想要从v_resort获取带有度假村名称的标签。这是主要困难的地方
l_qry := l_qry || 'sum(decode(resort_id,''' || r1.resort_id ||''',1,0)) test,';
l_qry := l_qry || 'sum(decode(resort_id,''' || r1.resort_id ||''',1,0)) '|| v_resort||',';
当您将鼠标悬停在列上时,第一行将显示“测试”标签。然而第二个用'|| v_resort ||'将导致不显示任何结果的问题...它不是给#no_data_found#消息但只是空白字段.. 其余的代码:
END LOOP;
--Trim off trailing comma
l_qry := rtrim(l_qry, ',');
--Append the rest of the query
l_qry := l_qry || ' from ENQUIRY E,resort r
where
e.enquiry_type=''AVAILR''
and e.enquiry_channel like '''||:P5_CHANNEL||'''
and trunc(e.created) >= '''||:P5_DATE_FROM||'''
and trunc(e.created) <= '''||:P5_DATE_TO||'''
and e.ENQUIRED_DATE > '''||:P5_DATE_FROM||'''
and ((NVL(:P5_AVAILABLE,''A'')=''A'') or ('''||:P5_AVAILABLE||'''=AVAILABLE))
and e.resort_id = r.id
and ((resort_id = '''||:P6_RESORT||''') or ('''||:P6_RESORT||''' like ''0''))
group by To_Char(ENQUIRED_DATE,''MON-YY''),TO_CHAR(ENQUIRED_DATE,''YYMM'')
Order By TO_CHAR(ENQUIRED_DATE,''YYMM'')';
return(l_qry);
END;
我累了'|| v_resort ||' ,'''|| v_resort ||'''。任何其他想法如何创建标签的价值从v_resort拿出度假村名称?