案例条件在Apex日历和SQL Develover中不起作用

时间:2018-11-15 16:06:32

标签: oracle plsql oracle-sqldeveloper oracle-apex

我创建的条件不会影响先端日历,因为这些条件适用于我在先端日历中创建的轮班。 在这种情况下有人可以帮我吗?

 create or replace PROCEDURE                                    check_task_turnos AS
    BEGIN
    FOR i IN (SELECT ID, calendar_start, calendar_end, estado, TIPO,
    ,CASE
    when to_number(to_char(calendar_start,'DD')) = to_number(to_char(sysdate,'DD'))
    AND to_number(to_char(calendar_start,'HH24')) >= 7 AND to_number(to_char(calendar_end,'HH24')) < 15   
    AND to_number(to_char(sysdate,'HH24')) >= 7    AND to_number(to_char(sysdate,'HH24')) >= 15 
    then 'apex-cal-yellow'
    when to_number(to_char(calendar_start,'DD')) = to_number(to_char(sysdate,'DD'))
    AND to_number(to_char(calendar_start,'HH24')) >= 15 AND to_number(to_char(calendar_end,'HH24')) < 23   
    AND to_number(to_char(sysdate,'HH24')) >= 15    AND to_number(to_char(sysdate,'HH24')) >= 23 
    then 'apex-cal-yellow'
    when to_number(to_char(calendar_start,'DD')) = to_number(to_char(sysdate,'DD'))
    AND to_number(to_char(calendar_start,'HH24')) >= 23 AND to_number(to_char(calendar_end,'HH24')) < 7   
    AND to_number(to_char(sysdate,'HH24')) >= 23    AND to_number(to_char(sysdate,'HH24')) >= 7 
    then 'apex-cal-yellow'
    else null  end
    FROM PASSAGEM
    where estado='Aceite'
    and TIPO='To Do'
    )

          LOOP
        -- registo no LOG , aqui nao registas na PASSAGEM, registas numa tabela ao lado de LOG para teres referencia de quando foi alterada a data da tarefa
                    INSERT INTO PASSAGEM_LOG(passagem_id,
                                            start_date,
                                            end_date   
                                            )
                                    VALUES(i.id ,  
                                            i.calendar_start+( 8/24) ,
                                          i.calendar_end +(8/24));
                 -- update das horas de inico e fim para posicionamento no calendario
                    UPDATE PASSAGEM
                    SET  calendar_start = i.calendar_start+(8/24) --incrementamos 8horas (periodod e um turno
                        ,calendar_end   = i.calendar_end+(8/24) --incrementamos 8horas (periodod e um turno
                    WHERE ID = i.ID;
                                END LOOP;
                               COMMIT;
                              END;

1 个答案:

答案 0 :(得分:1)

您应该真正学习如何正确设置代码格式;您发布的那本书很难阅读和理解。

关于您的问题:此过程使用游标FOR循环。漫长而丑陋的CASE

  • 没有别名
  • 在以后的过程代码中不再使用
    • 如果您打算使用它,请设置其别名(例如my_case),以便可以将其引用为i.my_case

那么,为什么您希望它在任何地方都可以做到什么?现在的样子,好像从未写过CASE一样。