1
當我運行此功能:問題使用任何運營商在PLPGSQL功能
CREATE OR REPLACE FUNCTION insert_styles(raw_styles text)
RETURNS integer AS
$BODY$
declare
arr_value TEXT[];
upper_limit INTEGER;
style_ids INTEGER[];
BEGIN
arr_value := string_to_array(raw_styles, ',');
upper_limit := array_upper(arr_value, 1);
RAISE NOTICE 'arr_value = %', arr_value;
SELECT music_style FROM music_style INTO style_ids WHERE name = ANY (arr_value);
RETURN upper;
END;
$BODY$
LANGUAGE plpgsql VOLATILE
COST 100;
與此查詢:
SELECT insert_styles('Techno,ddd,wer,WJKDF');
它給了我下面的錯誤:
NOTICE: arr_value = {Techno,ddd,wer,WJKDF}
ERROR: array value must start with "{" or dimension information
CONTEXT: PL/pgSQL function "insert_styles" line 10 at SQL statement
我只是無法弄清楚。我是postgres新手!
再見!
偉大!非常感謝! –