【发布时间】:2014-03-21 18:36:06
【问题描述】:
我可能在形成文字时做错了。假设我有一个像这样的简单存储过程:
CREATE OR REPLACE FUNCTION do_something(input_array composite_type[])
RETURNS SETOF text AS
$BODY$
DECLARE
temp_var composite_type;
BEGIN
FOR temp_var IN SELECT unnest(input_array) LOOP
return next temp_var.message;
END LOOP;
END
$BODY$
LANGUAGE plpgsql;
composite_type 定义为:
CREATE TYPE composite_type AS
(message text,
amount numeric(16,2));
执行这样的查询:
SELECT * FROM do_something('{"(test,11)","(test2,22)"}')
产生这个结果集:
(test,11.00)
(test2,22.00)
代替:
test
test2
我的文字有问题还是我应该以不同的方式访问message 字段?感谢您的任何建议。
【问题讨论】:
标签: sql postgresql stored-procedures plpgsql