hmchzb19 发表于 2016-12-29 16:23

请帮我看个函数出错的问题

这个函数定义如下: 我是从这一篇blog 上看来的:https://blog.interlinked.org/tutorials/postgresql.html

create or replace function jmember (j json, key text )
RETURNS text
LANGUAGE plv8
IMMUTABLE
AS $function$
var ej = JSON.parse(j);
if (typeof ej != 'object')
      return NULL;
return JSON.stringify(ej);
$function$;

The jmember function allows us to parse and read the JSON string and returns the member identified by key:select jmember(data, 'title') from jsontest;   jmember----------------- "right"(1 row) Andrew also shows how to build an index to speed up access times in his post.这个函数我不能成功执行 报错如下:

点击(此处)折叠或打开

[*]postgres=# select jmember(data, 'title') from jsontest;

[*]ERROR: SyntaxError: Unexpected token o
[*]DETAIL: undefined() LINE 0: [object Object



页: [1]
查看完整版本: 请帮我看个函数出错的问题