我是编写 PL/SQL 的新手。我有这个小代码,但由于主题错误而无法打印输出。
declare
output_tour_id varchar(4000);
begin
dbms_output.enable;
for r in
(
SELECT TOUR_ID FROM "/DSD/HH_RADELHD"
VERSIONS BETWEEN TIMESTAMP TO_TIMESTAMP('2015-04-02 18:00:00','YYYY-MM-DD HH24:MI:SS')
AND TO_TIMESTAMP('2015-04-02 18:30:00','YYYY-MM-DD HH24:MI:SS')
WHERE VERSIONS_OPERATION = 'D'
group by VERSIONS_STARTTIME, CLIENT, TOUR_ID
)
Loop
@/tmp/get.sql r.tour_id;
DBMS_OUTPUT.PUT_LINE (output_tour_id);
end loop;
end;
/
执行后出现此错误:
old 30: WHERE CLIENT = 100 and TOUR_ID = &1;
new 30: WHERE CLIENT = 100 and TOUR_ID = r.tour_id;
'100','100002039690','000001','0001398563','0050543675','10','C170','20150402070750','CET','1',' ','10',' ','91597','20150330',' ',
declare
*
ERROR at line 1:
ORA-01422: exact fetch returns more than requested number of rows
ORA-06512: at line 13
您的意见将不胜感激。先感谢您。
如何使我的代码正确执行?