sql_select_updatetime := 'SELECT min(updatetime) into V_updatetime FROM '||V_tablename||
                             ' WHERE fltno = '''||P_flightno||'''
                             and buydate = '''||V_buydate||'''
                             and godate = '''||V_godate||'''
                             and orgcity = '''||P_orgcity||'''
                             and descity = '''||P_descity||'''
                             and router = '''||P_router||'''';此动态语句测试后的sql语句是正确的,但在执行的时候报 缺失关键字错误

解决方案 »

  1.   

    带into的不是这么写的
    应该是execute immediate sql_select_updatetime Into V_updatetime而不是把into写到sql的字符串中
      

  2.   


    sql_select_updatetime := 'SELECT min(updatetime) FROM '||V_tablename||
      ' WHERE fltno = '''||P_flightno||'''
      and buydate = '''||V_buydate||'''
      and godate = '''||V_godate||'''
      and orgcity = '''||P_orgcity||'''
      and descity = '''||P_descity||'''
      and router = '''||P_router||'''';
    execute immediate sql_select_updatetime into V_updatetime;
      

  3.   

    如果是执行动态sql,按照楼上写法
    select into 是plsql写法,就是执行动态plsql,就得加上plsql块。
    sql_select_updatetime := 'begin SELECT min(updatetime) into :1 FROM '||V_tablename||
      ' WHERE fltno = '''||P_flightno||'''
      and buydate = '''||V_buydate||'''
      and godate = '''||V_godate||'''
      and orgcity = '''||P_orgcity||'''
      and descity = '''||P_descity||'''
      and router = '''||P_router||'''' || ';' || 'end;';
    EXECUTE IMMEDIATE sql_select_updatetime USING OUT V_updatetime;
      

  4.   

     sql_update := 'update '||V_tablename|| ' set spcode = '''||V_spcode||''',updatetime = '''||sysdate||''',ruletype = '''||V_ruletype||''',sid = '||V_sid||'
                                where fltno='''||P_flightno||'''
                               and buydate = '''||V_buydate||'''
                               and godate = '''||V_godate||'''
                               and flightflag = '''||P_flightflag||'''
                               and fltclass = '''||V_fltclass||'''
                               and router = '''||P_router||'''
                               and orgcity = '''||P_orgcity||'''
                               and descity = '''||P_descity||'''';那这个动态sql拼接的对吗
      

  5.   

    dbms_output.put_line(sql_update);
    test时 看看出来的SQL,直接放到sql窗口运行,就明白那里有错了。