+ -
当前位置:首页 → 问答吧 → 求助动态游标问题

求助动态游标问题

时间:2011-09-14

来源:互联网

下面这是我写的一个包体,在测试的时候会报找不到from关键字错误。因为急着用,一时找资料
没有找到解决办法。所以求助各位高手帮忙看下,
我把'select t.start_date '||' to '||' t.end_date, 这个地方改成select t.start_date 这样一个字段
就好用了。所以我怀疑是连接字符串这的毛病。可是业务需要这样,没找到解决办法。
create or replace package body AL_REPORT_FIRST is

  procedure get_price(p_starttime in varchar2,
                      p_endtime   in varchar2,
                      p_startcity in char,
                      p_endcity   in char,
                      p_recursor  out sys_refcursor)
  is
  begin
      open p_recursor for
           'select t.start_date '||' to '||' t.end_date,
           t.dep_location,
           t.arr_location,
           t.cost
           from LDATA.al_ticket_surcharge_t t
           where t.dep_location=:1
             and t.arr_location=:2
             and t.start_date>:3
             and t.end_date<:4'
           using p_startcity,p_endcity,p_starttime,p_endtime;
  end;
end AL_REPORT_FIRST;

作者: yumingde   发布时间: 2011-09-14

sql语句就不对啊。

作者: 昨夜袜子   发布时间: 2011-09-14

应该是这个sql语法有问题

作者: jboracle1981   发布时间: 2011-09-14

哪里不对么?我在纠结那的连接。不知道该怎么写?

作者: yumingde   发布时间: 2011-09-14



代码如下:

create or replace package body AL_REPORT_FIRST
is

  procedure get_price(p_starttime in varchar2,
                      p_endtime   in varchar2,
                      p_startcity in char,
                      p_endcity   in char,
                      p_recursor  out sys_refcursor)
  is
  begin
    open p_recursor for 'select t.start_date || :0 || t.end_date,
                                t.dep_location,
                                t.arr_location,
                                t.cost
                           from LDATA.al_ticket_surcharge_t t
                          where t.dep_location=:1
                            and t.arr_location=:2
                            and t.start_date>:3
                            and t.end_date<:4'
      using 'to', p_startcity, p_endcity, p_starttime, p_endtime;
  end;
end AL_REPORT_FIRST;







[ 本帖最后由 bell6248 于 2011-9-14 16:26 编辑 ]

作者: bell6248   发布时间: 2011-09-14

非常感谢。
真是让我汗颜啊,我咋就没想到呢。

作者: yumingde   发布时间: 2011-09-14

- -  SQL写错了 学习下,拼接SQL 可以拼好了再使用 减少错误

[ 本帖最后由 ccceleven 于 2011-9-14 16:32 编辑 ]

作者: ccceleven   发布时间: 2011-09-14