警告:oci_execute():ORA-00907:缺少右括号

时间:2015-12-13 18:36:11

标签: php sql oracle parentheses

我很难用我的代码解决这个问题。我还是Oracle / PHP / SQL的新手。我已经尝试了很多解决方案,但没有一个能够正常工作。这是代码和错误。

$searchsql = "
    SELECT rm.room_ID, rm.room_no
      FROM bsi_room rm
     WHERE rm.roomtype_id = ".$roomTypeId."
           AND rm.capacity_id = ".$capcityid."".$extraSearchParam."
           AND rm.room_id NOT IN
                  (SELECT resv.room_id
                     FROM bsi_reservation resv, bsi_bookings boks
                    WHERE     boks.is_deleted = FALSE
                          AND resv.bookings_id = boks.booking_id
                          AND resv.room_type_id = ".$roomTypeId."
                          AND (('".$this->mysqlCheckInDate."' BETWEEN boks.start_date AND DATE_SUB(boks.end_date, INTERVAL 1 DAY))
                           OR (DATE_SUB('".$this->mysqlCheckOutDate."', INTERVAL 1 DAY) BETWEEN boks.start_date AND DATE_SUB(boks.end_date, INTERVAL 1 DAY))               OR (boks.start_date BETWEEN '".$this->mysqlCheckInDate."' AND DATE_SUB('".$this->mysqlCheckOutDate."', INTERVAL 1 DAY))                         OR (DATE_SUB(boks.end_date, INTERVAL 1 DAY) BETWEEN '".$this->mysqlCheckInDate."' AND DATE_SUB('".$this->mysqlCheckOutDate."', INTERVAL 1 DAY))))";
  

警告:oci_execute():ORA-00907:缺少右括号

我在某处做错了吗?

2 个答案:

答案 0 :(得分:0)

该行:

AND (('".$this->mysqlCheckInDate."' BETWEEN boks.start_date AND DATE_SUB(boks.end_date, INTERVAL 1 DAY))))

应该有3个右括号字符而不是4.子查询块过早结束。

答案 1 :(得分:0)

知道了。我忘了把to_date放到所有日期数据类型中。现在好了