SQL Error [42883]: ERROR: operator does not exist: text || boolean when calling Redshift Stored Procedure

SQL Error [42883]: ERROR: operator does not exist: text || boolean when calling Redshift Stored Procedure

Redshift 新手,我在从 redshift 调用存储过程时遇到问题。我基于现有的 SP 创建了一个新的 SP,因为有一个额外的参数。该参数是 BOOL 类型,所以我想传入 true、false 或 null 作为我的 $8 参数,所有其他参数都是 varchar。 SP 已保留并保存,但是当我拨打电话时,我收到以下错误消息:

SQL Error [42883]: ERROR: operator does not exist: text || boolean
  Hint: No operator matches the given name and argument type(s). You may need to add explicit type casts.
  Where: SQL statement "SELECT  'select     
        code.title,
        sum(tax_inclusive_amount) as "Total spend"      
        from #temp_invoice_combined  join dw.codes code
        on code.code = item_codes
        where code."key" in (select "key" from dw.codes where "parent key" in
 (select key from dw.codes where "parent key" in (select "key" from dw.codes where "parent key" is null))) 
and currency in ' ||    || ' 
and days in ' ||    || ' 
and account = ' ||    || '
and supplier in ' ||    || ' 
and product_id in ' ||    ||' 
and item_codes in ' ||    ||' 
and country in ' ||    || '
and format = ' ||    || ' 
group by code.title order by 2 desc limit 10'"
PL/pgSQL function "top10_category" line 13 at open

温度 table 确实有 invoice_format 列。

调用的参数列表如下所示:

vstart_date date, vend_date date, vcurrency varchar, vdays varchar, vaccount_id varchar, vsupplier varchar, vproduct_id varchar, vcodes varchar, vcountry varchar, vformat bool, rs_out refcursor

这可能是我遗漏的一些非常小的东西,它确实说需要显式强制转换,但我在 $8::boolean 这样的参数中尝试过,但这也没有用。所以不确定在哪里投射。

我在select语句中使用的视图中的列也是bool类型。

如有任何解释,我们将不胜感激。

您只能将字符串连接在一起,而您正在尝试将字符串与布尔值连接起来。