gpt4 book ai didi

mysql - 顶点 ORA-01008 : not all variables bound on host variables

转载 作者:行者123 更新时间:2023-11-29 21:26:55 26 4
gpt4 key购买 nike

我正在使用需要动态 SQL 查询的 apex 环境。 Apex借助“经典报表(基于函数)”提供了此api。我希望您注意第 8 行。我的应用程序是,当我将其粘贴到 stackoverflow 中时,间距会变得困惑。现在的问题是我收到错误“ORA-01008:并非所有变量都绑定(bind)”,这很有趣,因为当我将第 8 行中的 :TEAM_SELECTOR 更改为“MYSQL”(这是团队名称)的内容时,然后这段代码可以正常工作。请注意,:TEAM_SELECTOR 也可以在返回的查询中使用,没有问题。我也在使用 APEX 5。

    DECLARE
v_time INT;
v_start_time int;
v_end_time int;
v_rownum int := 1;
v_max_shifts int;
v_location INT;
v_P4_team_selector varchar2(30) := :TEAM_SELECTOR;
BEGIN

select extract(hour from CAST(sysdate AS TIMESTAMP)) into v_time from dual;

select count(*) into v_max_shifts from oncall_shift
where team = v_P4_team_selector;

FOR i IN 0..v_max_shifts
LOOP

select start_time into v_start_time from (select * from oncall_shift where team =v_P4_team_selector)
where rownum = v_rownum;
select end_time into v_end_time from (select * from oncall_shift where team =v_P4_team_selector)
where rownum = v_rownum;
v_rownum := v_rownum + 1;

if v_time >= v_start_time and v_time <= v_end_time
then

select location into v_location from oncall_shift
where team = v_P4_team_selector
and start_time = v_start_time
and end_time = v_end_time;

return '
SELECT E.FNAME "First Name",E.LNAME "Last Name",E.OFFICE_NUM "Office Number", E.MOBILE_NUM "Mobile Number",L.NAME Location, o.position "Primary/Secondary"
FROM EMPLOYEE E, LOCATION L, ON_CALL O
WHERE E.ID = O.EMP_ID
AND L.ID = O.LOC_ID
AND O.ONCALL_DATE=TRUNC(SYSDATE)
AND O.TEAM=:TEAM_SELECTOR
AND L.ID = ' || v_location ||
' ORDER BY l.name asc
';
EXIT;

END IF;

END LOOP;
END;

最佳答案

好吧,我认为问题是基于函数的经典报告在主机变量(TEAM_SELECTOR)能够被绑定(bind)之前执行,因此抛出错误。我对此的解决方案是将其更改为基于 sql 查询的普通经典报告,该查询在绑定(bind)主机变量后运行,因为我需要一个单独的变量,我使用与期望更改“v_location”相同的查询在该页面上创建了一个 P1_LOCATION 项前往 P1_LOCATION。现在,我在 P1_LOCATION 页面项中放置了获取位置的过程。

P1_LOCATION 代码:

    DECLARE
v_time INT;
v_start_time int;
v_end_time int;
v_rownum int := 1;
v_max_shifts int;
v_location INT;
v_P4_team_selector varchar2(30) := :TEAM_SELECTOR;
BEGIN

select extract(hour from CAST(sysdate AS TIMESTAMP)) into v_time from dual;

select count(*) into v_max_shifts from oncall_shift
where team = v_P4_team_selector;

FOR i IN 0..v_max_shifts
LOOP

select start_time into v_start_time from (select * from oncall_shift where team =v_P4_team_selector)
where rownum = v_rownum;
select end_time into v_end_time from (select * from oncall_shift where team =v_P4_team_selector)
where rownum = v_rownum;
v_rownum := v_rownum + 1;

if v_time >= v_start_time and v_time <= v_end_time
then

select location into v_location from oncall_shift
where team = v_P4_team_selector
and start_time = v_start_time
and end_time = v_end_time;

APEX_UTIL.set_session_state('P1_LOCATION',v_location);

EXIT;

END IF;

END LOOP;
END;

经典报表(sql查询):

SELECT E.FNAME "First Name",E.LNAME "Last Name",E.OFFICE_NUM "Office Number", E.MOBILE_NUM "Mobile Number",L.NAME Location, o.position "Primary/Secondary"
FROM EMPLOYEE E, LOCATION L, ON_CALL O
WHERE E.ID = O.EMP_ID
AND L.ID = O.LOC_ID
AND O.ONCALL_DATE=TRUNC(SYSDATE)
AND O.TEAM=:TEAM_SELECTOR
AND L.ID = :P1_LOCATION
ORDER BY l.name asc

关于mysql - 顶点 ORA-01008 : not all variables bound on host variables,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35461248/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com