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语句是正确的,但在执行的时候报 缺失关键字错误。
' 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语句是正确的,但在执行的时候报 缺失关键字错误。
应该是execute immediate sql_select_updatetime Into V_updatetime而不是把into写到sql的字符串中
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;
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;
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拼接的对吗
test时 看看出来的SQL,直接放到sql窗口运行,就明白那里有错了。