在netezza中从nzplsql将参数传递给UDA时出错

时间:2013-10-26 04:04:40

标签: postgresql netezza

  • 我有一个表测试,其列有x0,x1,x2,x3
  • 我有一个UDA,它接受两列作为参数并进行一些计算
  • 我试图从我的nzplsq

  • 中调用UDA
  • 当我直接拨打UDA时如:

    create table newtable as select ncorrFactor(x0,x2) from test;
    

它有效

但是当我尝试这样做时:

p varchar;
p := X || 0 || '';

create table newtable as select ncorrFactor(p,x2) from test;

它给了我这个错误:

ERROR:  pg_atoi: error in "x0": can't parse "x0"

我需要修理什么?

1 个答案:

答案 0 :(得分:1)

假设第一个片段是用NZPLSQL编写的存储过程,p被视为'X0',您需要动态构建查询并在该查询中使用“execute immediate”。

例如:

declare
query varchar;
begin
 query:='create table newtable as select ncorrFactor('|| 0 ||',x2) from test';
 execute immediate query;
end;