将执行字符串的结果存储到临时 table
store result of execute string into temp table
在一个函数中,我创建了一个包含 Select 查询的字符串
SQLSTR:='select col1,col2 from '||_param1||'_'||_param2||' where col1 like ''%'||_pram3;
我想要的是在 运行 EXECUTE SQLSTR;
命令之后将 SQLSTR
的结果存储到临时 table 作为 FilterTable
。
为什么不直接使用 CTAS 语法?
SQLSTR :=
'create temp table FilterTable as select col1,col2 from '
|| quote_ident(_param1 || '_' || _param2)
||' where col1 like ''%' || _param3 || '''';
请注意,我还在语句末尾添加了一个缺少的结束引号,并使用 quote_ident()
作为 table 名称,以防它包含特殊字符。
在一个函数中,我创建了一个包含 Select 查询的字符串
SQLSTR:='select col1,col2 from '||_param1||'_'||_param2||' where col1 like ''%'||_pram3;
我想要的是在 运行 EXECUTE SQLSTR;
命令之后将 SQLSTR
的结果存储到临时 table 作为 FilterTable
。
为什么不直接使用 CTAS 语法?
SQLSTR :=
'create temp table FilterTable as select col1,col2 from '
|| quote_ident(_param1 || '_' || _param2)
||' where col1 like ''%' || _param3 || '''';
请注意,我还在语句末尾添加了一个缺少的结束引号,并使用 quote_ident()
作为 table 名称,以防它包含特殊字符。