Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/go/7.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
Pl/SQL生成的查询上的Oracle Apex唯一列别名_Sql_Oracle_Oracle Apex - Fatal编程技术网

Pl/SQL生成的查询上的Oracle Apex唯一列别名

Pl/SQL生成的查询上的Oracle Apex唯一列别名,sql,oracle,oracle-apex,Sql,Oracle,Oracle Apex,我试图获取由PL/SQL块动态拉入的查询的报告。 我从中得到灵感 列数是动态的,取决于循环: declare l_qry VARCHAR2(4300); s_qry VARCHAR2(80) := 0; v_resort_id NUMBER := 1; begin l_qry := 'select a.column1,'; FOR pci in ( select id,name from table_pci where resort_id = v_resort_id) LOOP s_qr

我试图获取由PL/SQL块动态拉入的查询的报告。 我从中得到灵感 列数是动态的,取决于循环:

declare
l_qry VARCHAR2(4300);
s_qry VARCHAR2(80) := 0;
v_resort_id NUMBER := 1;

begin

l_qry := 'select a.column1,';

FOR pci in ( select id,name from table_pci where resort_id = v_resort_id) LOOP

s_qry := s_qry||'package.some_function (a.id,''' || pci.id || ''' , ''PC'') Property_type,' ;

 END LOOP;

   l_qry := l_qry ||s_qry;

   l_qry := l_qry||'a.column2 from features a where a.feature_type = ''condition1'' ';


return(l_qry);

end;
属性_type是动态列上的硬编码别名,因此每次循环都会尝试生成具有相同名称和顶点的列,并将其标记为error。如果我选择 使用通用列名(仅在运行时解析查询)它返回正确的列数,但命名为Col1、Col2、Col3

如果我试图从表\u pci之类的名称中获取动态内容,我会尝试:

s_qry := s_qry||'package.some_function (a.id,''' || pci.id || ''' , ''PC'') '''|| pci.name || ''',' ;
我犯了一个错误

failed to parse SQL query:
ORA-00923: FROM keyword not found where expected
找到动态命名方法的任何帮助我都非常感激。
任何指针、任何建议和链接。

我认为您在尝试使用动态列别名时可能存在语法错误

尝试:

如果
pci.name
中的值可能包含空格,则用双引号将其括起来:

s_qry := s_qry||'package.some_function (a.id,''' || pci.id || ''' , ''PC'') AS "'|| pci.name || '",' ;

希望这会有帮助……

你是救生员。第二个选项起作用了-Apex的“| | pci.name | |”与“| | pci.name | |”有所不同,很高兴它有所帮助。如果将列别名括在双引号中(第二个示例),则它可以容忍空格和其他字符。
s_qry := s_qry||'package.some_function (a.id,''' || pci.id || ''' , ''PC'') AS "'|| pci.name || '",' ;