OrientDB SQL 函数参数值在函数体内不可访问
OrientDB SQL function parameter values are not accessible inside the function body
我试图在 OrientDB 中编写一个 SQL 函数来在 table Feature
上进行插入。函数体如下所示,它接受两个参数 w
和 t
。
insert into Feature (weight, title) values (w, t) return @rid
当我使用指定为 12
和 some title
的参数执行此函数时,我得到的响应是这样的。
[
{
"@type": "d",
"@rid": "#21:24135",
"@version": 1,
"@class": "Feature",
"weight": null,
"title": null
}
]
看起来好像还没有设置参数,因此值 12
和 some title
在函数中不可见。我还尝试在函数体中使用 $
之类的特殊字符在参数名称之前(将参数值称为 $t
而不是 t
),但仍然没有走运。
你能看到吗:"titile":null 而不是 "title",所以将这个插入到 Feature (weight, title) values (w, t) return @rid,它找不到要分配的属性,我想
我认为你执行了命令
insert into Feature (weight, title) values (w, t) return @rid
但是你在传递参数w和t时忘记插入引号了。
试试这个代码:
var g=orient.getGraph();
var ins = g.command('sql','insert into Feature (weight, title) values ('+w+', "'+t+'")');
return ins;
输出:
[
{
"@type": "d",
"@rid": "#12:-2",
"@version": 0,
"@class": "Feature",
"weight": 14,
"title": "sometitle",
"@fieldTypes": "weight=d"
}
]
希望对您有所帮助
您可以使用这个查询
insert into Feature (weight, title) values (:w, :t) return @rid
我试图在 OrientDB 中编写一个 SQL 函数来在 table Feature
上进行插入。函数体如下所示,它接受两个参数 w
和 t
。
insert into Feature (weight, title) values (w, t) return @rid
当我使用指定为 12
和 some title
的参数执行此函数时,我得到的响应是这样的。
[
{
"@type": "d",
"@rid": "#21:24135",
"@version": 1,
"@class": "Feature",
"weight": null,
"title": null
}
]
看起来好像还没有设置参数,因此值 12
和 some title
在函数中不可见。我还尝试在函数体中使用 $
之类的特殊字符在参数名称之前(将参数值称为 $t
而不是 t
),但仍然没有走运。
你能看到吗:"titile":null 而不是 "title",所以将这个插入到 Feature (weight, title) values (w, t) return @rid,它找不到要分配的属性,我想
我认为你执行了命令
insert into Feature (weight, title) values (w, t) return @rid
但是你在传递参数w和t时忘记插入引号了。 试试这个代码:
var g=orient.getGraph();
var ins = g.command('sql','insert into Feature (weight, title) values ('+w+', "'+t+'")');
return ins;
输出:
[
{
"@type": "d",
"@rid": "#12:-2",
"@version": 0,
"@class": "Feature",
"weight": 14,
"title": "sometitle",
"@fieldTypes": "weight=d"
}
]
希望对您有所帮助
您可以使用这个查询
insert into Feature (weight, title) values (:w, :t) return @rid