Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 带空格的别名列名引发错误_Sql_Oracle_Plsql_Oracle10g - Fatal编程技术网

Sql 带空格的别名列名引发错误

Sql 带空格的别名列名引发错误,sql,oracle,plsql,oracle10g,Sql,Oracle,Plsql,Oracle10g,我在存储过程中使用以下部分,它会抛出错误:- 错误报告: ORA-00923: FROM keyword not found where expected 问题在于列名中包含空格,我用粗体突出显示了这一行。它是字符串连接 //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;

我在存储过程中使用以下部分,它会抛出错误:- 错误报告:

ORA-00923: FROM keyword not found where expected
问题在于列名中包含空格,我用粗体突出显示了这一行。它是字符串连接

//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; 

您必须使用
executeimmediate
,如下所示:

//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;

您应该用双引号将整个列名括起来,但我不确定是否有一列或两列

sql_Columns ||',"T_'|| evt_label||'Total'||vTytCnt||'"


如果单个问题是列名中的空格,那么解决方法很简单:将它们放在双引号中:“堆栈溢出”。@Florin Ghinta,如何在下一个语句中使用双引号,sql_Columns:=sql_Columns | |',T| | | evt| u label | | |'“Total”| | vtycnt;问题不是在执行中,而是在下面几行的引号中:-sql|comm:=“从表1中选择”| | sql|列| |',T|“'| | evt| U标签| |”“总计”| vTytCnt | |”;
sql_Columns ||',"T_'|| evt_label||'","Total'||vTytCnt||'"'