我在我的存储过程中使用以下部分,它会抛出错误: - 错误报告:
ORA-00923: FROM keyword not found where expected
问题在于列名,其中包含以i粗体突出显示的行。它是字符串连接
//Evt_label has varchar values with spaces eg. Stack OverFlow
select TYT_LIBELLE into evt_label from trb_type_trv where tyt_id= x.tyt_id;
***sql_Columns := sql_Columns ||',T_"'|| evt_label||'"Total'||vTytCnt;***
//Error Comes when i execute this line
select sql_Columns from table1;
答案 0 :(得分:2)
您必须使用EXECUTE IMMEDIATE
,如下所示:
//Evt_label has varchar values with spaces eg. Stack OverFlow
select TYT_LIBELLE into evt_label from trb_type_trv where tyt_id= x.tyt_id;
sql_comm := 'select '||sql_Columns ||',T_"'|| evt_label||'"Total'||vTytCnt||' from table1';
//Error Comes when i execute this line
EXECUTE IMMEDIATE sql_comm;
答案 1 :(得分:0)
您应该用双引号括住整个列名,但我不确定是否有一列或两列
sql_Columns ||',"T_'|| evt_label||'Total'||vTytCnt||'"
或
sql_Columns ||',"T_'|| evt_label||'","Total'||vTytCnt||'"'