PostgreSQL的string_to_array双引号引起问题

时间:2018-11-04 13:16:06

标签: postgresql double quote

在下面的示例中,如果函数的参数为​​'WW123(TestTest 20)®TEST50®®40®France™WW123(TestTest 20)®TEst50®®40®Fra',则tss应等于check错误的检查将变为“ WW123(TestTest 20)(请注意在开头加上双引号)。

任何人都不知道问题出在哪里?是PostgreSQL 9.6中的错误吗?

CREATE OR REPLACE FUNCTION audit.test_function (
  a_test text
)
RETURNS text AS
$body$
DECLARE
v_combinations text[];
v_combination text;
v_combination_elements text [ ]; 
  tss text;
check text;  
BEGIN
v_combinations = string_to_array(a_test,'™');

FOREACH v_combination in array v_combinations
LOOP
v_combination_elements = string_to_array(v_combination,'®');

FOR i in 1..array_length(v_combination_elements,1)-2

loop
  tss = 'WW123 (TestTest 20)';
  check = v_combination_elements[i];
  if tss = v_combination_elements[i]
  then 
  return 'Yes';
  else
  return 'No';
  end if;
 end loop;

END LOOP;

  RETURN TSS;
END;    

0 个答案:

没有答案